2

This may be a dumb question, but I'm having problems running a Java Application from the command line using java -jar myapp.jar.

The same application runs perfectly inside eclipse when I use the menu to select "run as Java Application"

Can I somehow make eclipse show me in the console exactly what it's executing so I can replicate it via command line?

juan
  • 80,295
  • 52
  • 162
  • 195
  • Did you have a look into eclipse's run configurations? They tell you how they execute the JVM. – home May 09 '12 at 15:00
  • I don't know about that, but is this directory in your classpath? – MByD May 09 '12 at 15:03
  • @home, Yes, but eclipse has a textbox where you specify the entrypoint, and stuff like that. I assume that info is then translated to a command line... command. That's what I want to see. – juan May 09 '12 at 15:03
  • 1
    Ok, so you need the concrete command line instructions generated out of the eclipse run configurations? If so, +1, this is interesting :-) – home May 09 '12 at 15:05

2 Answers2

3

When you launch the app from Eclipse, go to the Debug Perspective and find the app in the Debug view. Right-click on the class name in the Debug tree (highlighted here in blue)

enter image description here

select Properties, and there you can see the command line that was used to launch the app.

E-Riz
  • 31,431
  • 9
  • 97
  • 134
0

Look in the run configurations (Run -> Run Configurations...) for the myapp Java Application run configuration.

The Main tab will show you the main class. This is the class you'll have to add to the command line, or specify when you build your runnable jar.

The Classpath tab will show you any other jars or class files that have to be specified on the class path when you build your jar.

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
  • Yes, thanks, I understand that. I'm having problems doing that by command-line, I'm obviously missing something that eclipse does. That's why I want to see the commands it executes. – juan May 09 '12 at 15:08
  • Try starting Eclipse with the -debug option, and see what shows up in the .log file. – Gilbert Le Blanc May 09 '12 at 15:17