tags:

views:

75

answers:

4

[if this is a dupe, tell me and I'll delete it immediately]

I would like to see the command that Eclipse is running when I hit run for a Java program. I've looked around the Eclipse preferences for Run/Debug (and console) and the Run Configurations, but to no avail. How can I see the line that Eclipse is using to launch?

In JBuilder, it was the first line in the output.

Edit: I'm not asking whether it uses javac to compile and then java to run. I want to see the line that starts with java and has all the flags, etc. I'm not asking "what does Eclipse run?" since I already know that. I want to see it in a specific case in a specific project.

+1  A: 

I believe it uses javac to get the class files then plain java to run those files.

Kyle
Eclipse has its own compiler, not related to javac.
nhnb
+2  A: 

If it can find any class with the main method, it runs that using "java com.example.Main" where Main is the class with main method.

If you have many classes with main method, then eclipse gives you an option to choose one.

Vishal
+3  A: 

Set up a launch configuration, then run or debug it.

Go to the "Debug" window of the Debug perspective, the one that shows all the processes and threads.

Right click on the java.exe or javaw.exe item in the tree (its at the bottom under all of the threadgroups and threads), and choose "Properties" on that guy.

You should get a window that contains 2 sections, the left being a list of items, including "process information" and "vm capabilities"

The process information section has 3 sections, showing the time it launched the session, the path to the exe, and the full command line that eclipse used to start the VM. The command line will include everything, including library paths, classpaths, the debug info it passes to the VM, any custom args you pass, etc.

I think that's what you're looking for.

John Gardner
Thanks John Gardner, that worked perfectly.
Yar
Excellent. I was just trying to find this `-Djava.library.path=` which I did. Now I know what I'm looking for.
Yar
hopefully you're mot messing with the library path manually. eclipse has a way of setting that up too! :)
John Gardner
@John Gardner, no, Eclipse is doing it fine, I wanted to find out how it's doing it (so I can do it without Eclipse). Thanks and good luck here on SO.
Yar
+1  A: 

On Unix systems you can see the command line with

ps -e x | grep java

For example (line wrapped for readability):

24925 pts/6    Sl     0:16 
/usr/lib/jvm/java-6-openjdk/bin/java 
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:53880 
-Dfile.encoding=UTF-8 
-Xbootclasspath:/usr/lib/jvm/java-6-openjdk/jre/lib/resources.jar
  :/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar
  :/usr/lib/jvm/java-6-openjdk/jre/lib/jsse.jar
  :/usr/lib/jvm/java-6-openjdk/jre/lib/jce.jar
  :/usr/lib/jvm/java-6-openjdk/jre/lib/charsets.jar
  :/usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar
  :/usr/share/java/gnome-java-bridge.jar 
-classpath /home/hendrik/workspace/webflag/WEB-INF/classes
  :/home/hendrik/workspace/webflag/WEB-INF/lib/log4j.jar
  :/home/hendrik/workspace/webflag/WEB-INF/lib/junit.jar
nhb.webflag.importtools.tools.ImportArmoryCharacter 

-agentlib specifies the debugging connection, -Xbootclasspath is based on the JDK configuration, -classpath based on the build path settings of the project

nhnb
+1 for this convoluted way to go, since it will work on the OSX system I'm on. Plus it's a pretty cool answer which sidesteps the problem of not knowing Eclipse too well.
Yar