简体   繁体   English

从Eclipse或Command提示符运行java

[英]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? 我想知道通过Eclipse IDE运行程序或使用命令行运行程序之间是否有任何区别? Memory-usage and performance-wise. 内存使用和性能方面。
I am using Java. 我正在使用Java。

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). 基本上,Eclipse运行与java.exe相同的JVM,因此在使用相同的JVM参数时不应该有任何性能下降(当然,如果您没有在调试模式下运行它)。

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). 但是,由于Eclipse在启动之前管理了很多东西,如果你必须启动多个JVM,那么最好有一个执行JVM的批处理文件/ shell脚本,因为在这种情况下从Eclipse启动JVM的开销可能会更高。明显更大(但是,发布应该没有差异)。

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. 只要确保JVM选项匹配,只需通过Eclipse 运行已编译的程序就像通过命令行运行它一样。 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. Eclipse默认调用用于运行Eclipse本身的JVM,尽管可以通过“ 运行配置”对话框设置JVM和任何命令行选项。

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. 但是,一个可能存在显着差异的事实是,使用命令行意味着您可以启动应用程序,而不会受到Eclipse的影响,Eclipse可能会占用大量CPU,并且有点内存耗尽,同时运行。 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. 虽然通过Eclipse运行不会直接影响程序的执行,但它仍然可以通过它在同一台计算机上的存在而产生影响。

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. Eclipse使用ECJ,它自己的增量Java编译器,而不是与JDK捆绑在一起的javac实现。 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. ECJ有一些额外的扩展,但它并不总是与当前的JDK完全兼容 - 我偶尔会发现生成的字节码存在差异,包括JDK编译器中没有的一些错误。

Eclipse itself is a java application that comes with a certain overhead, otherwise, no. Eclipse本身是一个带有一定开销的java应用程序,否则,没有。 Generally speaking, command line will outperform eclipse. 一般来说,命令行将胜过eclipse。

I would not have thought so. 我不会这么想的。

But obviously with Eclipse open, that will take up memory in itself. 但是很明显,在Eclipse打开的情况下,这将占用内存本身。

The run configurations can be saved and are more easily managed within Eclipse. 可以保存运行配置,并且可以在Eclipse中更轻松地进行管理。

my best thought is using the VisualVM for checking on meomry and cpu differences, but i would be suprised to see a huge difference. 我最好的想法是使用VisualVM检查meomry和cpu的差异,但我会惊讶地看到一个巨大的差异。 Another point is the classpath setting, there differences can/might occur. 另一点是类路径设置,可能/可能会出现差异。

regards 问候

Eclipse中的“运行配置”对话框允许您设置将在命令行上设置的所有参数,例如堆大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM