开发者

Eclim - What to set org.eclim.java.run.mainclass to?

I'm having trouble getting the :Java command to work in eclim. When I run it 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.NativeMetho开发者_StackOverflow中文版dAccessorImpl.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)

There seems to be a lot of explainations as how to fix this, such as this post on SO or here, but they all say to "setting the org.eclim.java.run.mainclass property of your project" through :ProjectSettings. My question is what do I set it to? No matter what I put when I try to write the changes vim says "Operation contained errors. See location list for details."


As I landed here from Google, I will post an answer:

You need to set the name of the class with main method. So for example, if you have just one class:

class HelloKittieTest {
  public static void main (String [] args)
  {
    System.out.println("Hello Kittie");
  }
}

Save the file, run :ProjectSettings command which will open the mentioned file and set:

org.eclim.java.run.mainclass=HelloKittieTest

Don't forget to save that one too. Now you should normally run :Java


@Ernest's answer is correct to run the main class for a project. However, if you want to run the main method for an arbitrary class you only need to pass the current file token % as an argument to the :Java command...

public class Foo{ 
    public static void main(String[] args) {
       System.out.println("I came from Foo");
    }
}

In command mode pass the current file token (%).

:Java %


though I have an entry "<classpathentry kind="src" path="src"/>" in .classpath, but it seems that you also need to run :NewSrcEntry src again to trigger eclim to refresh relative configuration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜