Errors deploying Applet created in Netbeans, using Netbeans and Swing
I've created an Applet with NetBeans. My partner used NetBean's Drag-and-Drop Swing editor for the interface. It runs perfectly fine with no exceptions or warnings when I right click on the applet file and click "run". However, it throws this exception when I build it and put the NetBeans generated html file on the apache server on my machine and run it.
Here is step by step what I'm doing to deploy it to my local server (~myHome/Sites/):
I click "clean and build"
I right click on the tab applet source file and select "run". It opens and runs fine in a new window. (It also creates a Applet.html file for testing, which is why I do it)
I run $ cp -r /build ~myHome/Sites This copies the html file for testing and the class folder with all the compiled classes to my sites folder
Open a web browser to the path and it gives an error and doesn't load
Here is the error from the console:
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@316d3536
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 260792 us, pluginInit dt 255591692 us, TotalTime: 255852484 us
network: Cache entry not found [url: http://***.edu/~myHomeDirectory/build/classes/org/jdesktop/layout/GroupLayout$Group.class, version: null]
network: Connecting http://~myHomeDirectory/Sites/build/classes/org/jdesktop/layout/GroupLayout$Group.class with proxy=DIRECT
network: Connecting http://***.edu:80/ with proxy=DIRECT
network: Connecting http://***.edu/~myHomeDirectory/Sitesbuild/classes/org/jdesktop/layout/GroupLayout$Group.class with cookie
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@316d3536
Exception in thread "thread applet-tab_interface/TabApplet.class-4" java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
at tab_interface.Mediator.<init>(Mediator.java:26)
at tab_driver.TabDriver.<init>(TabDriver.java:86)
at tab_interface.TabApplet.init(TabApplet.java:69)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Plugin2Manager.java:1640)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: org.jdesktop.layout.GroupLayout$Group
at sun.plugin2.applet.Applet2ClassLoader.findClass(Applet2ClassLoader.java:252)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Plugin2ClassLoader.java:250)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:180)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Plugin2ClassLoader.java:161)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 5 more
So I guess my main questions are:
Is there something extra I have to do to deploy and applet created using the NetBeans Swing editor?
Any suggestions about what should do next to tackle this problem? I've followed the exception and it leads to Mediator line 26... which is:
gui = new AppletGUI();
That line is the constructor for the GUI class created by NetBeans Swing Editor. Here's some basic code to show whats going on. The applet, GUI, GUIMediator are in one package and the TabDriver is in its own.
class MyApplet extends Applet{
GUIMediator gui;
TabDriver driver;
init(){
driver = new TabDriver(...); // TabDriver creates a mediator
gui = driver.getMediator();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
}
});
} catch (InterruptedException ex) {
开发者_高级运维 ...
} catch (InvocationTargetException ex) {
...
}
}
void createGUI(){
this.add(gui.getGUI()); // add JPanel to Applet
}
}
class TabDriver {
TabDriver (...) {
this.mediator = new GUIMediator(this);
}
}
class GUIMediator {
TabDriver driver;
JPanel GUI;
GUIMediator(TabDriver td) {
driver = td;
GUI = new TabGUI();
}
}
class TabGUI extends JPanel {
TabGUI() {
// super();
// init();
// initListeners();
// ...
}
}
Note that everything in the TabGUI is commented out and that it still throws the exception when TabGUI is initialized in a web browser.
Sorry this is so long.
Thank you, -N
It looks like GroupLayout
is unavailable. As it's new in version 1.6, you might check your installed JRE.
精彩评论