6

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.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)

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."

Community
  • 1
  • 1
ciferkey
  • 2,064
  • 3
  • 20
  • 28

3 Answers3

9

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
  • 8,701
  • 5
  • 40
  • 51
5

@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 %
Edward J Beckett
  • 5,061
  • 1
  • 41
  • 41
0

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.

zhaozhi
  • 1,491
  • 1
  • 16
  • 19