我正在尝试在Debian GNU/Linux 9 (stretch)上使用Nailgun。"Nailgun是一个客户端、协议和服务器,可以在命令行上运行Java程序,而不会产生JVM启动开销。程序在服务器上运行(该服务器由Java实现),并由客户端(用C编写)触发,客户端处理所有I/O。"一些文档如下:
这个程序运行正常。
运行客户端(
但以下内容无法运行:
编译客户端:
但以下内容无效:
- Nailgun快速入门
- JVM启动时间/Nailgun
- 如何使用nailgun服务器提高java性能
- DSpace/Nailgun
我使用Oracle Java版本10.0.2(我也尝试过GraalVM 1.0.0-rc9 Java 1.8.0_192)。
一个简单的Java程序进行测试: TestVarargs.java。 (最终我想要运行一个JAR文件,但我尝试了这个简单的例子,因为它不起作用。)
$ wget https://bitbucket.org/OPiMedia/hellanguages/raw/default/Java/standard/TestVarargs/TestVarargs.java
$ javac TestVarargs.java
$ java TestVarargs
这个程序运行正常。
第一次尝试,使用Debian nailgun包(版本0.9.1-3)
安装:
$ sudo apt-get remove nailgun
启动服务器:
$ java -jar /usr/share/java/nailgun-server.jar &
NGServer 0.9.1 started on all interfaces, port 2113.
运行客户端(
/usr/bin/ng-nailgun
):$ ng-nailgun ng-version
NailGun server version 0.9.1
但以下内容无法运行:
$ ng-nailgun ng-cp
java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/java.net.URLClassLoader
at com.martiansoftware.nailgun.builtins.NGClasspath.nailMain(NGClasspath.java:65)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:280)
$ ng-nailgun TestVarargs
java.lang.ClassNotFoundException: TestVarargs
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:291)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:242)
$ ng-nailgun ng-alias TV TestVarargs
java.lang.ClassNotFoundException: TestVarargs
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:291)
at com.martiansoftware.nailgun.builtins.NGAlias.nailMain(NGAlias.java:79)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:280)
停止命令运行正常:
$ ng-nailgun ng-stop
com.martiansoftware.nailgun.builtins.NGAlias: 2/0
com.martiansoftware.nailgun.builtins.NGClasspath: 5/0
com.martiansoftware.nailgun.builtins.NGServerStats: 0/0
com.martiansoftware.nailgun.builtins.NGStop: 1/1
com.martiansoftware.nailgun.builtins.NGVersion: 1/0
NGServer shut down.
第二次尝试,从GitHub源代码构建
$ wget https://github.com/facebook/nailgun/archive/master.zip
$ unzip master.zip
$ cd nailgun-master
使用Maven编译服务器:
$ mvn clean install
...
[INFO] BUILD SUCCESS
...
编译客户端:
$ make
启动服务器:
$ java -jar nailgun-server/target/nailgun-server-1.0.0.jar &
NGServer 1.0.0 started on all addresses, port 2113.
运行客户端:
$ nailgun-client/target/ng ng-version
NailGun server version 1.0.0
但以下内容无效:
$ nailgun-client/target/ng ng-cp
(既没有输出也没有错误消息。)
$ cd ..
$ nailgun-master/nailgun-client/target/ng TestVarargs
(既无输出也无错误信息。)
$ nailgun-master/nailgun-client/target/ng ng-alias TV TestVarargs
(既没有输出,也没有错误信息。)
停止命令正常运行:
$ nailgun-master/nailgun-client/target/ng ng-stop
NGServer shut down.