简体   繁体   English

通过nailgun运行Java程序

[英]Running a java program via nailgun

Can someone please explain how do I start a program called main.java using Nailgun. 有人可以解释一下如何使用Nailgun启动名为main.java的程序。 It's been a complete nightmare for me and I cannot find any sort of tutorial on the web which explains it clearly. 对我来说,这真是一场噩梦,我在网络上找不到任何可以清楚解释它的教程。

Do I need to include anything extra in my program to run them? 我是否需要在程序中包含其他任何内容才能运行它们?

I'm trying to follow the instructions given on the Nailgun website where it says: 我正在尝试遵循Nailgun网站上的指示,该网址上写着:

Launch the Nailgun server with "java com.martiansoftware.nailgun.NGServer"

But the output I get is: 但是我得到的输出是:

Error: Could not find or load main class com.martiansoftware.nailgun.NGServer

Also, when I try to run my compiled java program, the output is: 另外,当我尝试运行已编译的Java程序时,输出为:

java.lang.ClassNotFoundException: main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:274)
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:261)

I think the idea with nailgun is that you have to include the classpath when you launch the server , like this: 我认为nailgun的想法是,启动服务器时必须包含类路径,如下所示:

$ java -cp /usr/share/java/nailgun-0.9.0.jar:path/to/myapp.jar -server com.martiansoftware.nailgun.NGServer 127.0.0.1 &
NGServer started on 127.0.0.1, port 2113.
[1] 22443
$ ng-nailgun com.user4215685.main

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM