简体   繁体   English

部署JApplet:ClassNotFoundException

[英]Deploying a JApplet: ClassNotFoundException

Edit 2: I created a html in the root directory and placed the jar file in the same place, I could then get the applet to run (though I had some issues with self-signed security). 编辑2:我在根目录中创建了一个html并将jar文件放置在同一位置,然后可以使applet运行(尽管我在自签名安全性方面存在一些问题)。 This tells me the problem is in the applet code. 这告诉我问题出在applet代码中。 Any ideas why it wouldn't find the class when if I can remove the codebase attribute it runs correctly? 任何想法,如果我可以删除codebase属性,为什么它无法正常运行,为什么找不到该类?

Edit 1: I have updated the entry point to remove the frame. 编辑1:我已经更新了入口点以删除框架。 I also tested with the HelloWorld applet and still received the same error. 我还使用HelloWorld小程序进行了测试,但仍然收到相同的错误。


I'm fairly new to Java so I'll try to explain my problem as clearly as I can and with plenty of detail. 我对Java还是很陌生,所以我将尽我所能并详尽地解释我的问题。 If I miss anything please let me know. 如果我错过任何事情,请告诉我。 I'm also aware that this problem is frequently asked about on here, I've done a fair bit of research and found conflicting responses and nothing that worked. 我也知道这里经常有人问这个问题,我做了相当多的研究,发现矛盾的反应无济于事。

I have developed a JApplet in eclipse, exported a jar file for the project and am attempting to deploy it on my website. 我已经在eclipse中开发了一个JApplet,为该项目导出了一个jar文件,并试图将其部署到我的网站上。 However, when I attempt to view the applet online I get the error: ClassNotFoundException. 但是,当我尝试在线查看小程序时,出现错误:ClassNotFoundException。 It is probably also worth mentioning that I am trying to deploy this JApplet through wordpress. 可能还值得一提的是,我正在尝试通过wordpress部署此JApplet。

Here is the html code I'm using to deploy: 这是我用来部署的html代码:

<applet code = 'gui.ConverterGUI.class' 
    codebase = 'http://www.myurl.co.uk/Java/'
    archive = 'AConverter.jar'
    width = 800
    height = 600>
    <param name="permissions" value="all-permissions" />
</applet>

My applet has a few packages and classes which I think I have set up and exported correctly, but incase that is causing problems, here is my main entry point: 我的小程序有一些程序包和类,我认为我已经正确设置和导出了这些程序包和类,但是如果这引起了问题,这是我的主要切入点:

public class ConverterGUI extends JApplet {
// Current program ver.
public static final double VERSION = 0.0;


public void init() {
    // Make it look nicer.
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch(Exception e) {
        e.printStackTrace();
    }



    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            createAndShowGUI();
        }
    });
}


    private void createAndShowGUI() {
        System.out.println("Created GUI on EDT? "+
                SwingUtilities.isEventDispatchThread());

        //JFrame f = new JFrame("Converter GUI");
        ResultDisplay resultDisplay = new ResultDisplay();
        getContentPane().add(resultDisplay, BorderLayout.CENTER);
        getContentPane().add(new InputFields(resultDisplay), BorderLayout.NORTH);
    }
}

我的项目套件设定

This is my project layout. 这是我的项目布局。

I've exported the jar using Eclipse, I've got the impression that this means it has been signed properly already, but if this is not the case and it is causing issues, I'd appreciate being pointed in the right direction to do this (I do have eclipse set up with the JDK rather than JRE). 我已经使用Eclipse导出了jar,给人的印象是,它已经被正确签名了,但是如果不是这种情况,并且会引起问题,我将为正确的方向做准备。这(我确实使用JDK而不是JRE设置了Eclipse)。

The issue was in the html code and the way wordpress was interpreting it. 问题出在html代码和wordpress解释它的方式中。 For future reference, I fixed the issue by removing the lines from the html code and using double quotes, as follows: 为了将来参考,我通过从html代码中删除行并使用双引号来解决此问题,如下所示:

<applet code = "gui.ConverterGUI.class" codebase="http://www.myurl.co.uk/Java/" archive="AConverter.jar" width=800 height=600><param name="permissions" value="all-permissions" /></applet>

Nonetheless I did get some useful advice here. 尽管如此,我的确得到了一些有用的建议。 Thanks all. 谢谢大家

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

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