Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the inline command launch by eclipse

Tags:

java

eclipse

I would like to see what Eclipse executes on the command-line when launching my Java program. How can I access this?

For example, to run myClass.class, Eclipse will use something similar to this: java.exe -classpath "H:\Eclipse_workspace\Example1\bin;.... myClass.class. Is there a way to get this command?

like image 682
scsin75 Avatar asked Aug 09 '10 10:08

scsin75


2 Answers

If you're using a launch configuration, you can follow these steps to get the Java command executed by Eclipse to run your program with that configuration:

  1. Run the program with the specific launch configuration
    1. Right click the Main class
    2. Select Run As > Run Configurations...
    3. Setup the configuration to your needs
    4. Click apply and then run
  2. Switch to the Debug perspective (Window > Open Perspective > Debug)
  3. In Debug perspective, find the window pane titled Debug
  4. In the Debug window pane, find the line for the Virtual Machine
    enter image description here
  5. Right-click the Virtual Machine and select Properties
  6. In Process Properties there is the Command Line section which contains exactly the command that Eclipse used to run your program.
like image 148
Achim Lörke Avatar answered Oct 14 '22 05:10

Achim Lörke


You could use the RuntimeMXBean within the application that is launched by eclipse.

RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
List<String> paramList=new ArrayList<String>();
paramList.addAll( RuntimemxBean.getInputArguments() );
paramList.add(  RuntimemxBean.getClassPath() );
paramList.add(  RuntimemxBean.getBootClassPath()  );
paramList.add(  RuntimemxBean.getLibraryPath()  );

for( String p : paramList ) {
    System.out.println( p ); 
}
like image 25
stacker Avatar answered Oct 14 '22 04:10

stacker