简体   繁体   中英

Applet won't start using Applet runner from Intellij Idea

I have an applet, which I can run fine from the browser, but when I try to run it from the Applet configuration in Intellij Idea, it doesn't start because it can't find some classes. The definition of applet in the page looks like this(from the startApp.jsp which I use for starting it):

<applet mayscript archive="/library1.jar.pack.gz, /library2.jar.pack.gz, .." 
   code="com.company.library1.MainApplet" codebase="/"
   type="application/x-java-applet;version=1.6.0_20" align = "top" border = "0" height = "860" hspace = "0" width = "1250" vspace  = "0">
   <--some parameters-->        
</applet>

The class not found is MainApplet , which is inside the library1.jar.pack.gz

Is there some way to make it work also from the applet viewer and not from the web page? I don't get any other exception than this:

/usr/lib/jvm/java-7-oracle/bin/java -Djava.security.policy=/home/user/SW/idea-IU-133.696/bin/appletviewer.policy -Djnlp.packEnabled=true -Didea.launcher.port=7535 
-Didea.launcher.bin.path=/home/user/SW/idea-IU-133.696/bin -Dfile.encoding=UTF-8 -classpath 
/home/user/SW/idea-IU-133.696/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain 
sun.applet.AppletViewer http://localhost:8080/startApp.jsp
load: class com.company.library1.MainApplet not found.
java.lang.ClassNotFoundException: com.company.library1.MainApplet
at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:219)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:152)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:633)
at sun.applet.AppletPanel.createApplet(AppletPanel.java:793)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:722)
at sun.applet.AppletPanel.run(AppletPanel.java:379)
at java.lang.Thread.run(Thread.java:744)

The Applet Viewer in IntelliJ IDEA is geared towards running applets you are working on in your project. That said, you can run one from a library JAR. Looking at the first four lines of your output, I am not seeing the library1 on your class path. Thus java cannot find the MainApplet class. In the Applet Viewer configuration dialog there is a " Use classpath of module " option. Set that to the IDEA module that has the library1 dependency in its classpath (ie in its list of dependencies). As a caveat, while I know it will work for a JAR file, I'm not sure about a Pack200 file off hand. I'd be curious though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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