Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

vim

eclim

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

like image 240
ciferkey Avatar asked Sep 12 '11 22:09

ciferkey


2 Answers

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

like image 173
Ernest Avatar answered Nov 15 '22 08:11

Ernest


@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 %
like image 20
Edward J Beckett Avatar answered Nov 15 '22 08:11

Edward J Beckett