[Solved]Fatal Exception occured when running jar file [modified]
-
I'm writing a program using BlueJ. I created a jar file and set the Main class to the desired class. When I run the jar in Explorer I get an error window saying "Java Virtual Machine Launcher. Fatal Exception occured. Program will exit." I have a Main method which instantiates a class which extends JFrame. I wrapped that in a try-catch block to see if there was an error on my code. The message still appears. Is there a way to get a more verbose error? *Edit* Okay I ran it on my linux machine and this is the error:
jordanwb@jordanwb-laptop:/media/DEFB-0C36/PhpDesigner$ java PhpDesigner.jar
Exception in thread "main" java.lang.NoClassDefFoundError: PhpDesigner/jar
Caused by: java.lang.ClassNotFoundException: PhpDesigner.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: PhpDesigner.jar. Program will exit.So it can't fine the class, but how do I go about fixing that? Apparently the compiler and BlueJ can find the MainWindow class but the virtual machine can't.
modified on Thursday, January 7, 2010 4:16 PM
-
I'm writing a program using BlueJ. I created a jar file and set the Main class to the desired class. When I run the jar in Explorer I get an error window saying "Java Virtual Machine Launcher. Fatal Exception occured. Program will exit." I have a Main method which instantiates a class which extends JFrame. I wrapped that in a try-catch block to see if there was an error on my code. The message still appears. Is there a way to get a more verbose error? *Edit* Okay I ran it on my linux machine and this is the error:
jordanwb@jordanwb-laptop:/media/DEFB-0C36/PhpDesigner$ java PhpDesigner.jar
Exception in thread "main" java.lang.NoClassDefFoundError: PhpDesigner/jar
Caused by: java.lang.ClassNotFoundException: PhpDesigner.jar
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: PhpDesigner.jar. Program will exit.So it can't fine the class, but how do I go about fixing that? Apparently the compiler and BlueJ can find the MainWindow class but the virtual machine can't.
modified on Thursday, January 7, 2010 4:16 PM
-
Jordanwb wrote:
jordanwb@jordanwb-laptop:/media/DEFB-0C36/PhpDesigner$ java PhpDesigner.jar
I think that should be:
java -jar PhpDesigner.jar
jordanwb@jordanwb-laptop:/media/DEFB-0C36/PhpDesigner$ java -jar PhpDesigner.jar
Exception in thread "main" java.lang.NoSuchMethodError: mainThe main method does exist in the startup class. :confused:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;public class MainWindow extends JFrame implements ActionListener
{
private JMenuBar main_menu;private JMenu file\_menu; private JMenuItem new\_project, open\_project, save\_project, save\_project\_as, quit; private JMenu objects\_menu; private JMenuItem add\_folder, add\_file, add\_class, add\_interface, add\_function, add\_parameter, add\_field; private JPanel php\_object\_manager; public MainWindow() { super ("PhpDesigner"); this.setSize (800, 600); this.setDefaultCloseOperation(JFrame.EXIT\_ON\_CLOSE); /\* Set up main menu \*/ /\* Set up file menu \*/ this.new\_project = new JMenuItem("New Project", new ImageIcon ("./Images/document-new.png")); this.new\_project.addActionListener (this); this.open\_project = new JMenuItem("Open Project", new ImageIcon ("./Images/document-open.png")); this.open\_project.addActionListener (this); this.save\_project = new JMenuItem("Save Project", new ImageIcon ("./Images/document-save.png")); this.save\_project.addActionListener (this); this.save\_project\_as = new JMenuItem("Save Project As", new ImageIcon ("./Images/document-save-as.png")); this.save\_project\_as.addActionListener (this); this.quit = new JMenuItem("Quit", new ImageIcon ("./Images/system-log-out.png")); this.quit.addActionListener (this); this.file\_menu = new JMenu ("File"); this.file\_menu.add (this.new\_project); this.file\_menu.addSeparator(); this.file\_menu.add (this.open\_project); this.file\_menu.add (this.save\_project); this.file\_menu.add (this.save\_project\_as); this.file\_menu.addSeparator(); this.file\_menu.add (this.quit); this.main\_menu = new JMenuBar (); this.main\_menu.add (this.file\_menu); this.getContentPane().add (this.main\_menu, BorderLayout.NORTH); /\* End of setting up file menu \*/ /\* Set up Objects menu \*/ this.add\_folder = new JMenuItem ("Add Folder"); this.add\_file = new JMenuItem ("Add Fil
-
jordanwb@jordanwb-laptop:/media/DEFB-0C36/PhpDesigner$ java -jar PhpDesigner.jar
Exception in thread "main" java.lang.NoSuchMethodError: mainThe main method does exist in the startup class. :confused:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.*;public class MainWindow extends JFrame implements ActionListener
{
private JMenuBar main_menu;private JMenu file\_menu; private JMenuItem new\_project, open\_project, save\_project, save\_project\_as, quit; private JMenu objects\_menu; private JMenuItem add\_folder, add\_file, add\_class, add\_interface, add\_function, add\_parameter, add\_field; private JPanel php\_object\_manager; public MainWindow() { super ("PhpDesigner"); this.setSize (800, 600); this.setDefaultCloseOperation(JFrame.EXIT\_ON\_CLOSE); /\* Set up main menu \*/ /\* Set up file menu \*/ this.new\_project = new JMenuItem("New Project", new ImageIcon ("./Images/document-new.png")); this.new\_project.addActionListener (this); this.open\_project = new JMenuItem("Open Project", new ImageIcon ("./Images/document-open.png")); this.open\_project.addActionListener (this); this.save\_project = new JMenuItem("Save Project", new ImageIcon ("./Images/document-save.png")); this.save\_project.addActionListener (this); this.save\_project\_as = new JMenuItem("Save Project As", new ImageIcon ("./Images/document-save-as.png")); this.save\_project\_as.addActionListener (this); this.quit = new JMenuItem("Quit", new ImageIcon ("./Images/system-log-out.png")); this.quit.addActionListener (this); this.file\_menu = new JMenu ("File"); this.file\_menu.add (this.new\_project); this.file\_menu.addSeparator(); this.file\_menu.add (this.open\_project); this.file\_menu.add (this.save\_project); this.file\_menu.add (this.save\_project\_as); this.file\_menu.addSeparator(); this.file\_menu.add (this.quit); this.main\_menu = new JMenuBar (); this.main\_menu.add (this.file\_menu); this.getContentPane().add (this.main\_menu, BorderLayout.NORTH); /\* End of setting up file menu \*/ /\* Set up Objects menu \*/ this.add\_folder = new JMenuItem ("Add Folder"); this.add\_file = new JMenuItem ("Add Fil
-
How did you create your 'jar'; did you use a correct manifest file to identify the class containing the
main()
method? -
Jordanwb wrote:
I used BlueJ
I'm afraid I know nothing about BlueJ so you need to go to the documentation to check it out. Alternatively you could deconstruct the jar file and check the files yourself.
-
Interesting; I actually wondered about that yesterday, but did not bother to test it out. To paraphrase Sherlock Holmes: "When you have eliminated the impossible, whatever remains, however improbable, must be the answer".
-
It sortof makes sense. Java apps are capable of processing arguments, altough they're infrequently used on Windows. Another thing I forgot was that the first letter of a method is always lowercase. I had to rename Main (String[]) to main (String[]).
-
I had upgraded QuickBooks 2009 to 2010 edition for my dad. The conversion started off at taking four hours, then down t 2 and a half hours, down to twelve minutes then down to 3. The whole process took around 2 minutes.