Hossein
Hossein

Reputation: 41821

Running java from Eclipse or Command prompt

I want to know if there is any difference between running a program through Eclipse IDE or running it using command-line? Memory-usage and performance-wise.
I am using Java.

Upvotes: 5

Views: 3063

Answers (6)

thkala
thkala

Reputation: 86333

Just running a compiled program through Eclipse should be the same as running it via the command line, as long as you make sure that the JVM options match. Eclipse by default calls the JVM that was used to run Eclipse itself, although the JVM and any command line options can be set up via the Run Configurations dialog.

One possibly significant difference though, is the fact that using the command line means that you can launch your application without the impact of having Eclipse, which can be quite CPU-intensive and somewhat of a memory hog, running at the same time. While running through Eclipse does not affect the execution of the program directly, it can still have an effect just by its presence on the same computer.

That said, there is a difference if by "running through command-line" you also imply the compilation process as well. Eclipse uses ECJ, its own incremental Java compiler, rather than the javac implementation bundled with the JDK. ECJ has some additional extensions, but it is not always fully compatible with the current JDK - I have occasionally found differences in the produced bytecode, including a few bugs that were not present in the JDK compiler.

Upvotes: 2

Zoltán Ujhelyi
Zoltán Ujhelyi

Reputation: 13858

Basically, Eclipse runs the same JVM as java.exe, so there should not be any performance decrease when using the same JVM parameters (of course if you are not running it in debug mode).

However, as Eclipse manages a lot of things before launching, if you have to launch several JVMs, it might be better to have a batch file/shell script that executes the JVMs, as in this case the overhead of launching a JVM from Eclipse might be noticeably bigger (however, there should be no difference after the launch).

Upvotes: 3

Thomas Z.
Thomas Z.

Reputation: 11

my best thought is using the VisualVM for checking on meomry and cpu differences, but i would be suprised to see a huge difference. Another point is the classpath setting, there differences can/might occur.

regards

Upvotes: 1

enkor
enkor

Reputation: 7557

I would not have thought so.

But obviously with Eclipse open, that will take up memory in itself.

The run configurations can be saved and are more easily managed within Eclipse.

Upvotes: 1

James Raitsev
James Raitsev

Reputation: 96381

Eclipse itself is a java application that comes with a certain overhead, otherwise, no. Generally speaking, command line will outperform eclipse.

Upvotes: 1

Russell Zahniser
Russell Zahniser

Reputation: 16354

The "run configurations" dialog in Eclipse allows you to set all the parameters that would be set on the command line, like heap size.

Upvotes: 0

Related Questions