Reputation: 7894
I've got a simple java program, socket, AWT and jUnit dependencies.
I've built it in eclipse and when I run/debug it from eclipse it works.
When I launch it from the command line I get an error saying
Exception in thread "main" java.lang.NoClassDefFoundError
I'm guessing it's due to not finding one of the required dependencies in the classpath.
Given that launching from eclipse works, Is there a way of determining what command line eclipse uses to launch the same program?
Upvotes: 7
Views: 1641
Reputation: 51445
You're asking 2 different questions here.
You can check your Java project's classpath by right clicking on the project name, and left clicking on the Properties option at the bottom.
On the Properties dialog, left clicking on the Java Build Path brings up the build path dialog.
If you want to determine the Eclipse command line string, you look at the Run Configurations. On the menu, left click on Run, then left click on Run Configurations. Under Java Application, you should find the run configuration for your project. The Arguments tab shows you how Eclipse starts your Java project.
Upvotes: 1
Reputation: 23171
It looks like your classpath isn't set appropriately when you try to run via the command line. You can easily export the command Eclipse uses by doing this:
Upvotes: 14
Reputation: 13914
The classpath that Eclipse will use should be visible in your project's properties dialog...
Or, on a Unix-like system, you can cheat, with something like (Linux/Fedora) ps axww | grep java
to peek around for the actual command-line.
On Linux, specifically, /proc/
pid/cmdline
will give the entire command-line (split with '\0' chars, so it may look run-together if you just cat
the file) and /proc/
pid/environ
will show environment variables, if you need to peek at them, as well. (e.g. CLASSPATH
environment variable)
Upvotes: 1