Eclipse: is there a way to get Eclipse to output the commands given to run your program?

喜欢而已 提交于 2019-12-06 01:42:59

问题


I'm having some build issues with Eclipse in that it runs my app just fine in eclipse but for some reason when trying to run using

#>java MyClass

it ends up not running due to not being able to find the class. This makes no sense so I was wondering if there was a way to have eclipse output what it's feeding into the jvm to get it to build/run.

Is this possible?

Thanks


回答1:


you can get the exact command used by Eclipse like this:

  1. Run your program inside Eclipse.
  2. Go to the Debug perspective.
  3. Terminate the program, or let it end. right click on the second line. (Terminated, exit value... ) and select properties. in there you will have the full command line used.



回答2:


I don't know of any way of getting Eclipse to show any command line arguments - but I'm sure we can solve your problem in other ways.

  • What is the full name of your class? Is it just MyClass, or is it in some package? You need to supplied the fully qualified name, e.g.

    java mypackage.MyClass
    
  • Where are the class files? You need to make sure they're on the class path, e.g.

    java -classpath bin mypackage.MyClass
    



回答3:


Once you have run a program in eclipse, there is configuration available from the 'debug' and 'run' menus. If you open it, you will see the classpath. From there you can determine what it did.

You can also check the box that writes the launch config to a .launch file, and look at it. It's not precisely the command line, but it will tell you what you need to know.




回答4:


Eclipse does not pass anything to your java application unless you tell it to in the launch configuration. Check your classpath and your packages, like Jon Skeet already wrote.




回答5:


Does not Eclipse show the commands in one of the Consoles?




回答6:


Note: if you want to see the exact java command line Eclipse is launching when running your app (from Eclipse), you can:

  • put a breakpoint at the beginning of your class
  • launch your app in debug mode
  • launch a Process Explorer (if you are on Windows, that is)


(source: maximumpc.com)

You will see under the eclipse.exe (not shown in this picture) the java process.
Double-click on it, go the the Image tab, and copy-paste the value of the field "command-line".



来源:https://stackoverflow.com/questions/1989419/eclipse-is-there-a-way-to-get-eclipse-to-output-the-commands-given-to-run-your

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!