user176121
user176121

Reputation: 720

How to run a java program using eclim?

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.

Upvotes: 4

Views: 4449

Answers (2)

spirossi
spirossi

Reputation: 363

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.

Upvotes: 10

Andrzej Doyle
Andrzej Doyle

Reputation: 103777

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.

Upvotes: 5

Related Questions