简体   繁体   English

java,eclipse jar问题

[英]java , eclipse jar problem

i'm kind of new to java. 我是Java的新手。 I use eclipse and i imported some jar files with some classes by going to properties -> Add External Jars; 我使用eclipse,并通过转到属性->添加外部Jars,导入了带有某些类的一些jar文件。 The problem is that when i try to use a class from the jar i get the following exception: 问题是,当我尝试使用jar中的类时,出现以下异常:

Exception in thread "main" java.lang.NoClassDefFoundError: nextapp/echo2/app/event/ActionListener at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) at Program.main(Program.java:12) Caused by: java.lang.ClassNotFoundException: nextapp.echo2.app.event.ActionListener at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 13 more

The class is supposed to create a window, i guess that the jar has to import somehow other stuff or something like that, How can i fix this? 该类应该创建一个窗口,我想罐子必须以某种方式导入其他东西或类似的东西,我该如何解决呢?

PS. PS。 Sorry for the bad code , i don't know tags here. 对不起,错误的代码,我在这里不知道标签。

thansk, Raxvan 坦克斯(Raskvan)

Most jars you download will include 0-5 other jars that are needed. 您下载的大多数jar将包含0-5个其他需要的jar。 They all need included in order to use the jar. 他们都需要包括在内才能使用罐子。 Very quickly you end up with 20 jars in a simple 1000 line Java project, but thems are the breaks. 很快,您在一个简单的1000行Java项目中最终得到了20个jar,但是它们只是个突破。

Look inside your downloaded jar zip. 查看下载的jar压缩文件。 Should be a lib directory or such with all the libs you need. 应该是一个lib目录或包含您需要的所有lib的目录。

Another way to get around this would be to use a tool like Ivy or Maven to manage downloading dependencies. 解决此问题的另一种方法是使用IvyMaven之类的工具来管理下载依赖项。 Depending on what libraries you are using, you may have many transitive dependencies, and doing that all by hand will end up taking a lot of time. 根据所使用的库,您可能会具有许多传递依赖项,而手工完成这些操作将花费大量时间。

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

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