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

3

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

Inesinescapable answered 12/9, 2011 at 22:33 Comment(0)
B
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

Bernardinebernardo answered 18/2, 2012 at 18:54 Comment(0)
A
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 %
Arango answered 3/10, 2014 at 3:15 Comment(0)
I
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.

Interface answered 23/3, 2015 at 10:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.