Help: App runs fine in Studio but get nothing when running dist/jar file?
Good Day,
I hope someone else might be able to help me out. I am new to java and already stumped on an issue. I created a small application in SE 8 and it will run/debug fine when in the studio. But if I build the jar file and try running it by double clicking the jar file I get nothing. I have even tried to copy the jar file to another pc with the same result. I eventually go into the task manager to kill the javaw.exe to free up the file. One thing I did try was putting a "showMessageDialog" above the "setVisible(true)" for my form and I get the dialog but no form...
It just blows my mind how everything runs great in the IDE as expected, but when you create the jar file you get nothing?
Thanks in advance!
Jake
[753 byte] By [
jake99a] at [2007-10-3 2:39:56]

> Probably because you did something wrong. May I see
> your main class's code for a beginning?
Sorry, you are probably right about me doing something wrong? I am a C# developer by trade and looking for a new challenge by jumping to Java for a while. Thanks for the quick responce and help !
Here is my entry class:
package lasso;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
import baseWizard.*;
public class LassoWizard extends javax.swing.JFrame implements baseWizard.WizardListener {
/** Creates new form LassoWizard */
public LassoWizard() {
initComponents();
this.setTitle("");
this.setResizable(false);
this.addWindowListener(createAppCloser());
wizard1.addWizardListener(this);
wizard1.start(new WelcomeStep());
wizard1.setVisible(true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
wizard1 = new baseWizard.Wizard();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
wizard1.setMaximumSize(new java.awt.Dimension(700, 500));
getContentPane().add(wizard1, java.awt.BorderLayout.CENTER);
pack();
}
// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new LassoWizard().setVisible(true);
}
});
}
private static WindowListener createAppCloser() {
return new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
};
}
/** Called when the wizard finishes.
* @param wizard the wizard that finished.
*/
public void wizardFinished(Wizard wizard) {
System.out.println("wizard finished");
System.exit(0);
}
/** Called when the wizard is cancelled.
* @param wizard the wizard that was cancelled.
*/
public void wizardCancelled(Wizard wizard) {
System.out.println("wizard cancelled");
System.exit(0);
}
/** Called when a new panel has been displayed in the wizard.
* @param wizard the wizard that was updated
*/
public void wizardPanelChanged(Wizard wizard) {
System.out.println("wizard new panel");
}
// Variables declaration - do not modify
private baseWizard.Wizard wizard1;
// End of variables declaration
}
Hey jake99.
Two things in particular caught my attention:
import baseWizard.*;
This was the first major one. What is the baseWizard package? If you are referencing this package from the library manager in sun studio, this may be the problem. You see what happens is when you hit that magic button to compile your project, it packs a lovely little jar file for you, and dumbly forgets to package any supporting library files with it. You need to copy all your library jar files into the same directory and include them in the class path.
second thing.
For another reason, the magic button will not make an executable jar. Either that or I havent found out how to do it yet. I fixed the problem by manually creating the jar using the jar tool in the command prompt.
jar -cmf MANIFESTFILE myPackagedJar.jar *.java
where MANIFESTFILE contains the path to the class with main method. Doing this should enable an executable jar file.
Are you using windows? Another way to take the hassle out of all this stuff is to download Xenoage Java Exe Starter (free program) and construct an exe file that launches your jar file in all its glory. That way you can specify all libraries in the class path from just double clicking the out put file exe.
Hope this helps.
Jason Barraclough.