How to run a java program using eclim?

三世轮回 提交于 2019-12-10 17:23:20

问题


I can't seem to run a simple Hello World program using eclim. I followed the install guide at http://eclim.org/guides/install.html#guides-install and the tutorial at http://eclim.org/gettingstarted.html#gettingstarted, but when I try to run the program (using :Java) I get

java.lang.RuntimeException: Required setting 'org.eclim.java.run.mainclass' has not been set.
    at org.eclim.plugin.jdt.command.src.JavaCommand.execute(JavaCommand.java:107)
    at org.eclim.command.Main.main(Main.java:89)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:334)

And I don't know how to set whatever it says I didn't set. The program successfully compiles, and I can run it regularly in terminal, I am using Ubuntu 9.10, java jdk 1.6, eclim 1.5.4.


回答1:


It looks like eclim doesn't have the property set that identifies your application's main class. According to http://eclim.org/vim/java/java.html you should be able to remedy this by setting the org.eclim.java.run.mainclass property of your project (to the fully-qualified name of your application's main class).

EDIT - responding to comment:

I'm not familiar with eclim, but I would expect that since this is a project property, you would set it once and from that point on it should be persisted along with the project.

On the other hand, if you want to have multiple main classes that could be invoked and switch between them, then of course you'll need to provide some kind of extra config. How would you expect eclim to know which one you meant by just typing :Java? There might be some nice syntactic sugar you can use to register multiple classes and invoke them as "java 1", "java 2" etc. - but at the end of the day you will always need some way of distinguishing between which class you're thinking of running.




回答2:


Thought I'd add a more satisfying answer since this topic came up on top in a few Google searches I did ...

By calling :Java % the file that is currently edited will be run. See here for more details.



来源:https://stackoverflow.com/questions/1945886/how-to-run-a-java-program-using-eclim

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