want help to create jar file
Hi....
To Run my project user should install some software抯.. so I want to create a JAR file
Using that user can install my software抯.
I have created a JAR file using?jar cvfm Test. jarmanifest.mf gsv48w32.exe jdk-1_5_0_06-windows-i586-p.exe ?it is working fine. Only when those two .exe file are in the directory where my jar file is executing
But I want to give only Test.jar to users I don抰 want to give gsv48w32,Jdk 1.5.
Is there any way to create a jar file.
Thanks
Graj
[526 byte] By [
raj83a] at [2007-11-27 8:41:37]

# 1
i am sending the code i used
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Container;
public class DefaultSample {
public static void main(String args[]) {
JFrame frame = new JFrame("Default Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
if(actionEvent.getActionCommand()=="press this button if u want to install Gsview")
{
try{
Runtime.getRuntime().exec("gsv48w32.exe");
}
catch(Exception e)
{}
}
else
{
try{
Runtime.getRuntime().exec("jdk-1_5_0_06-windows-i586-p.exe");
}
catch(Exception e)
{}
}
}
};
JPanel panel = new JPanel();
JButton defaultButton = new JButton("press this button if u want to install Gsview");
defaultButton.addActionListener(actionListener);
panel.add(defaultButton);
JButton otherButton = new JButton("press this button if u want to install java 1.5");
otherButton.addActionListener(actionListener);
panel.add(otherButton);
Container contentPane = frame.getContentPane();
contentPane.add(panel);
frame.getRootPane().setDefaultButton(defaultButton);
frame.setSize(700,600);
panel.setVisible(true);
frame.setVisible(true);
}
}
raj83a at 2007-7-12 20:40:39 >

# 2
Hi,
so if you want to pack all your classes and be able to run you app only typing:
% java -jar MyJar.jar
You need to specify a manifest file when you create the jar file with the flag 'm' (try using jar --help for more info) that points to your main class. For example:
% jar cvfm MyJar.jar manifest.MF -C bin .
creates a jar called MyJar.jar with the classes on the directory bin and uses the manifest file manifest.MF. The manifest file looks like:
Manifest-Version: 1.2
Main-Class: org.example.xtreme.ApplicationRun
Created-By: 1.4 (Sun Microsystems Inc.)
Its pointing to the class I use to run my application, called ApplicationRun.
Note: the exe files are invoked in the code of your program, they should be on the working dir when the java app is launched or it wont be able to execute the exe's!
gl