2

I have coded an applet requiring 1 library jar file (prowser-0.2.0). I have tested it on eclipse (3.6) and it works but when i put it on my html website, i have got the following error. I have impoted pbrowser library from project properties => Java Build Path => Libraries => Add external Jar. This code works in runnable jar and as applet in Eclipse.

Error from Java Console :

"Exception in thread "thread applet-myapplet.class-4" java.lang.NoClassDefFoundError: Could not initialize class com.zenkey.net.prowser.Prowser at myapplet.init(myapplet.java:8) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source)"

Applet code :

import java.applet.Applet;
import com.zenkey.net.prowser.*;
public class myapplet extends Applet {

public void init() {

    Prowser prowser = new Prowser();
    Tab tab = prowser.createTab();
    System.out.println(tab.go("http://www.google.com").getPageSource());    

   }
}

Html code :

<html>
<head>
<title> hello world </title>
</head>

<body>
This is the applet:<P>
<applet code="myapplet.class" archive="hello.jar,prowser-0.2.0.jar" width="150" height="50">
</applet>
</body>
</html>

Really Thanks for help !

user895063
  • 23
  • 1
  • 3

1 Answers1

3

Are hello.jar and prowser-0.2.0.jar in the same directory as the HTML file in your web server that serves the HTML? The applet seems to find hello.jar as your error message indicates. The prowser-0.2.0.jar needs to be added to the same directory as a separate file, not being packed inside hello.jar itself (as Eclipse allows you to do if you select "export as runnable jar").

Then I'd also check the manifest file of hello.jar to see whether it contains unusual Class-Path entries for the prowser Jar. It should not contain any relative or absolute path information, just the file name itself.

emboss
  • 38,880
  • 7
  • 101
  • 108
  • yes hello.jar and prowser library are in the same directory as the html file. I haven't export it as runable jar but as jar file, i have just add prowser library as external jar library file in the Java build Path in Eclipse. – user895063 Aug 15 '11 at 15:23
  • I edited the post, you could also check the Jar's manifest file. – emboss Aug 15 '11 at 15:30
  • the manifest file : Manifest-Version: 1.0 Class-Path: prowser-0.2.0.jar – user895063 Aug 15 '11 at 15:38
  • Beats me then, I'm sorry. Is Javascript an option for you? Then you could try [deploying using a JNLP file](http://download.oracle.com/javase/7/docs/technotes/guides/jweb/deployment_advice.html#deplToolkit). – emboss Aug 15 '11 at 15:51
  • Thanks for your help, i have solved my problem, i have imported directly source from the library in my project but now i have got a return "null" as response but when i execute it on eclipse i have the correct response. I will create another thread for this issue. – user895063 Aug 15 '11 at 20:12
  • `prowser-0.2.0.jar` should it be mentioned in classpath of manifest file inside `helloworld.jar`? – Nikolay Kuznetsov Jan 04 '13 at 08:01