Eclim - 将 org.eclim.java.run.mainclass 设置为什么?

发布于 2024-12-04 14:46:22 字数 1017 浏览 0 评论 0原文

我无法让 :Java 命令在 eclim 中工作。当我运行它时,我得到:

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)

似乎有很多关于如何解决此问题的解释,例如 这篇帖子在SO或这里,但他们都说通过 :ProjectSettings“设置项目的 org.eclim.java.run.mainclass 属性”。我的问题是我该如何设置它?无论我尝试编写更改时输入什么内容,vim 都会显示“操作包含错误。有关详细信息,请参阅位置列表。”

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅忆流年 2024-12-11 14:46:22

当我从 Google 来到这里时,我将发布一个答案:

您需要使用 main 方法设置类的名称。例如,如果您只有一个类:

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

保存文件,请运行 :ProjectSettings 命令,该命令将打开提到的文件并设置:

org.eclim.java.run.mainclass=HelloKittieTest

不要忘记也保存该文件。现在您应该正常运行 :Java

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

小苏打饼 2024-12-11 14:46:22

@Ernest 的答案对于运行项目的主类是正确的。 ,如果您想运行任意类的 main 方法,您只需将当前文件标记 % 作为参数传递给 :Java 命令...

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

但是 命令模式传递当前文件标记(%)。

: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 %
软糖 2024-12-11 14:46:22

虽然我有一个条目“”在.classpath中,但似乎还需要再次运行 :NewSrcEntry src 来触发 eclim 刷新相关配置。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文