java.lang.ClassNotFoundException : org. reSTLet.service.TunnelService 命令行

标签 java jar classnotfoundexception restlet

我正在使用ReSTLet框架。

我正在尝试从使用 Eclipse 创建的 jar 文件运行我的项目,方法是:导出->可运行的 JAR 文件,然后选择选项将所需的库打包到生成的 jar 中。

但是,当我尝试在命令行中执行 jar 文件时,输入:

java -Djava.security.policy=Client.Policy -jar identiscopeRunnable.jar 

我得到以下信息:

Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: org/restlet/service/TunnelService
at rest.IdentiscopeServer.main(IdentiscopeServer.java:24)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.restlet.service.TunnelService
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:423)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 6 more

我已经将从 ReSTLet Framework 下载的所有 jar 文件添加到我的项目中,所以我认为这不是它们的问题。有人对此有任何线索吗?

以防万一有人问起,IdentiscopeServer.java 的第 24 行是:

IdentiscopeServerApplication identiscopeServerApp = new IdentiscopeServerApplication();

IdentiscopeServerApplication 基本上执行以下操作:

@Override
public Restlet createInboundRoot() {
    Router router = new Router(getContext());

    //attaches the /tweet path to the TweetRest class
    router.attach("/collectionPublic", CollectionPublicREST.class);
    router.attach("/collectionPrivate", CollectionPrivateREST.class);
    router.attach("/analysis", AnalysisREST.class);
    return router;
}

最佳答案

将 jar 添加到 eclipse 项目不会将 jar 添加到命令行类路径。

java -cp <add your jars here separated by ';'(win) or ':'(linux) > -Djava.security.policy=Client.Policy -jar identiscopeRunnable.jar 

看看这是否有帮助。

关于java.lang.ClassNotFoundException : org. reSTLet.service.TunnelService 命令行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18900085/

相关文章:

java.sql.SQL语法错误异常 : ORA-00972: identifier is too long

java - 在jTable中添加复选框

java - 如何将 .dic 和 .aff 文件添加到 java jar 中?

maven - 如何使用maven将输出jar放入另一个文件夹?

java - 连接到 Azure 数据库时出现 ClassNotFoundException

java - 错误 : "Syntax error on token " ;", , expected" Why?

java - 如何将 Maven 构建的工件部署到 SourceForge 文件发布系统?

java - 如何创建jar文件?

java - 加载 : class MyApplet not found : java. lang.ClassNotFoundException。当包中存在类文件时,为什么我会收到此消息?

Eclipse 上的 Java 构建路径错误