使用具有多个类的applet

时间:2013-06-28 14:40:15

标签: java tomcat applet classpath japplet

我是applets的新手所以请耐心等待我。

我有一个japplet类,它使用了几个类,我想从浏览器运行它。 我正在使用Tomcat来运行applet,我找不到将其他类链接到Japplet类。

在哪里放其他课程?或任何其他有助于我解决这个问题的想法。

我的HTML

<html>
<title>Test Applet</title>
<hr>
<applet class="Main.class" width="320" height="120">
</applet>
<hr>
</html>

我的小程序类:

import javax.swing.JApplet;
import com.getSlide.MainApp;

public class Main extends JApplet {

    public void init() {
        System.out.println("init");
        MainApp main = new MainApp();
    }
}

1 个答案:

答案 0 :(得分:1)

  

在哪里放其他课程?

这取决于它们所在的包。如果它们在Main(如class="Main.class"暗示)的默认包中,则为同一目录。

OTOH最好将这些课程放入Jar中。

  

如何从小程序中调用jar?

假设Jar被称为the.jar ..

<html>
<title>Test Applet</title>
<hr>
<applet code="Main" archive="the.jar" width="320" height="120">
</applet>
<hr>
</html>

另请注意:

class="Main.class"

应该是:

code="Main"
相关问题