出口的Java小程序与引用的库 [英] Export Applet Java with referenced libraries

查看:216
本文介绍了出口的Java小程序与引用的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有codeD需要1库jar文件(prowser-0.2.0)的小程序。我已经测试它的Eclipse(3.6)和它的作品,但是当我把它放在我的HTML网站,我已经得到了下面的错误。我从项目属性=> Java构建路径=>库=>添加外部JAR impoted pbrowser库。
这code工作在运行的JAR和小程序在Eclipse。

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.

从Java控制台错误:

Error from Java Console :

异常螺纹线程applet的myapplet.class-4java.lang.NoClassDefFoundError的:无法初始化类com.zenkey.net.prowser.Prowser
      在myapplet.init(myapplet.java:8)
      在sun.plugin2.applet.Plugin2Manager $ AppletExecutionRunnable.run(来源不明)
      在java.lang.Thread.run(来源不明)

"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)"

小程序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 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 !

推荐答案

是hello.jar和prowser-0.2.0.jar在同一目录作为Web服务器的HTML文件,提供的HTML?小程序似乎找到hello.jar为您的错误消息表示。该prowser-0.2.0.jar需要被添加到同一个目录作为一个单独的文件的的被包装内hello.jar本身(如Eclipse允许你做,如果你选择导出为可运行罐子)。

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").

然后我还检查hello.jar的清单文件,看它是否包含prowser瓶不寻常的类路径项。它不应该包含任何相对或绝对路径信息,只需将文件名本身。

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.

这篇关于出口的Java小程序与引用的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆