Request for help understanding an applet deployment error message
Hello all.
So I've been trying to deploy an applet so I can test it out (I freely admit, I'm not even sure if it works) and I've tried it both directly and with a JNLP file, but either way I do it, when I try to embed it in an HTML file like so:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Wounded Web Page</title>
</head>
<!-- Written to deploy the text adventure Wounded -->
<body>
<h1><b>Wounded</b></h1>
<h2>Disclaimer:</h2>
My little pony is the property of Hasbro, Lauren Faust, and
the rest of its creative team. Please support the official release.
<p>
<p>
This text adventure is associated with the Equestria daily
fan-fiction "The First Prince" and many of the events that
occur here are relevant to what happens there.
<p>
<p>
<script src="http://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
code:'GUI', width:1309, height:683} ;
var parameters = {jnlp_href: 'wounded.jnlp'} ;
deployJava.runApplet(attributes, parameters, '1.6');
</script>
</body>
</html>
It refuses to run and when I ask for details as to why I get the following error message:
Code:
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.jdesktop.layout.GroupLayout$Group
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.JNLP2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 20 more
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
I honestly have no clue what this means and would really appreciate it if anyone would be able to help me figure it out. Thank you all for reading.
Re: Request for help understanding an applet deployment error message
Re: Request for help understanding an applet deployment error message
Okay, I've added code tags as best as I can, though honestly I'm not even sure what the second code type is, it's just the error explanation I got when I tried to display the HTML page.
Re: Request for help understanding an applet deployment error message
Quote:
Originally Posted by
chaucer345
It refuses to run and when I ask for details as to why I get the following error message:
Code:
java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
An error message can't get much clearer than that. The code evidently makes use of org.jdesktop.layout.GroupLayout.Group, and that class can't be found on the classpath.
Either migrate the Applet to use javax.swing.GroupLayout which is a part of the JDK since Java 1.6, or make the org...GroupLayout available on the classpath. I would recommend the former.
db
Re: Request for help understanding an applet deployment error message
Quote:
Originally Posted by
DarrylBurke
An error message can't get much clearer than that. The code evidently makes use of org.jdesktop.layout.GroupLayout.Group, and that class can't be found on the classpath.
Either migrate the Applet to use javax.swing.GroupLayout which is a part of the JDK since Java 1.6, or make the org...GroupLayout available on the classpath. I would recommend the former.
db
Okay, I'm very new so the terminology is somewhat strange to me. I was using the form provided by the NetBeans IDE to create the applet code, and I see what you were talking about in the method below:
Code:
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
output = new javax.swing.JTextArea();
choiceButton = new javax.swing.JButton();
input = new javax.swing.JTextField();
choiceLabel = new javax.swing.JLabel();
output.setColumns(20);
output.setRows(5);
jScrollPane1.setViewportView(output);
choiceButton.setText("Choose");
choiceButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
choiceButtonActionPerformed(evt);
}
});
input.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
inputActionPerformed(evt);
}
});
choiceLabel.setText("Choice:");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(150, 150, 150)
.add(choiceLabel)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(input, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 676, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(choiceButton))
.add(layout.createSequentialGroup()
.add(47, 47, 47)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1060, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(202, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(26, 26, 26)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 546, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 47, Short.MAX_VALUE)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(input, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(choiceLabel)
.add(choiceButton))
.add(39, 39, 39))
);
}// </editor-fold>
The IDE won't let me modify that code, but I can definitely see what you're saying as the applet class extends javax.swing.JApplet, so using methods from a javax.swing class would work perfectly.
Is there someway I can gain access to org.jdesktop.layout.GroupLayout methods without modifying the method above, possibly with an import?
Thank you so much for your help.
Edit: When I try to do that, it just says the import is unused
Edit2: When I try making a new jar file from that and open the html page, there's no outlined space with an error message. Side note: when I attempt to just run the .jar file I compiled I get an error message from the java virtual machine that reads:
Could not find the main class: GUI ((the name of the main class of my applet)). Program will exit.
Re: Request for help understanding an applet deployment error message
A visual designer is not a begiinners' tool. And a jar'ed Applet is not run outside of a browser by the Java executable but by the AppletViewer executable.
Frankly, you've bitten off more than you can chew. You need to get a better foundation in Java before you start dabbling in GUIs and Applets. Here's a good learning resource: The Java™ Tutorials
Also, you're probably using a hugely outdated version of NetBeans.
db
Re: Request for help understanding an applet deployment error message
Quote:
Originally Posted by
DarrylBurke
A visual designer is
not a begiinners' tool. And a jar'ed Applet is
not run outside of a browser by the Java executable but by the AppletViewer executable.
Frankly, you've bitten off more than you can chew. You need to get a better foundation in Java before you start dabbling in GUIs and Applets. Here's a good learning resource:
The Java™ Tutorials
Also, you're probably using a hugely outdated version of NetBeans.
db
So, if I came back later with a GUI I built from scratch would you be willing to help?