开发者

java.lang.NoClassDefFoundError with external jars in java applet

开发者 https://www.devze.com 2023-03-28 23:11 出处:网络
I have a Java applet which utilizes multiple external jars.In Eclipse the project runs fine.When it is exported and run embedded in a HTML file I get 22 run-time exceptions similar to..

I have a Java applet which utilizes multiple external jars. In Eclipse the project runs fine. When it is exported and run embedded in a HTML file I get 22 run-time exceptions similar to..

java.lang.RuntimeException: java.lang.NoClassDefFoundError: 
    mil/dcgs/mdf/webservice/ddms/ingest/CatalogIngestService

..with various classes. When I open the exported jar 开发者_开发知识库I see no .class files or any other traces from the external jar.

HTML

The HTML is:

<html> 
<head> 
<title>DIB Applet</title> 
</head> 
<body> 
<applet 
    code="org.mitre.inception.Main.class" 
    archive="inception.jar" 
    WIDTH = "1020" 
    HEIGHT = "500">
Applet
</applet> 
</body> 
</html> 

.classpath

My .classpath looks like the following.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="lib" path="C:/Users/myUserName/Desktop/jars/dcgs-util.jar"/>
    <!-- more jars removed for space reasons as they look the same as above -->
    <classpathentry kind="output" path="bin"/>
</classpath>


The classpath mentions dcgs-util.jar. That should probably be listed in the archive attribute of the applet element. Perhaps something like:

<html> 
<head> 
<title>DIB Applet</title> 
</head> 
<body> 
<applet 
    code="org.mitre.inception.Main.class" 
    archive="inception.jar,jars/dcgs-util.jar" 
    WIDTH = "1020" 
    HEIGHT = "500">
Applet
</applet> 
</body> 
</html> 

That would be assuming inception.jar was in the same directory as the HTML, and that dcgs-util.jar is in the jars sub-directory of the dir. where the HTML is located.


Try by using the following classpath. I just changed the order of the jar files.

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="lib" path="C:/Users/myUserName/Desktop/jars/dcgs-util.jar"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>    
    <!-- more jars removed for space reasons as they look the same as above -->
    <classpathentry kind="output" path="bin"/>
</classpath>
0

精彩评论

暂无评论...
验证码 换一张
取 消