Hello !
I am doing JAVA in this semester. Can anyone tell me how can i create
a java executable without using batch file. Is it possible ?
How can i hide the console when showing dialog boxes in swing ?
Plz help
_____________
Ali Arman Tamal
A newbie question :-)
Moderator: Board moderators
- Ali Arman Tamal
- Learning poster
- Posts: 76
- Joined: Sat Jan 15, 2005 5:04 pm
- Location: Dhaka
- Contact:
Java executable? From what I understand the Java compiler from Sun Microsystems does not produce executables but .class files containing bytecode.
From my knowledge of Java, you can compile all your Java source codes using javac *.java.
You might want to look up the asant utility which is similar to make for C/C++ programs.
I am not familiar with swing though.
From my knowledge of Java, you can compile all your Java source codes using javac *.java.
You might want to look up the asant utility which is similar to make for C/C++ programs.
I am not familiar with swing though.
- Ali Arman Tamal
- Learning poster
- Posts: 76
- Joined: Sat Jan 15, 2005 5:04 pm
- Location: Dhaka
- Contact:
The jar utility may be what you are looking for: http://java.sun.com/docs/books/tutorial/jar/
Here is a short working example:
Dummy.java:
DummyFrame.java:
Manifest.txt:
Run these two commands:
Then, the file runme.jar will be created. Double-clicking it will run the Dummy.class. (If .jar is associated with other program, e.g. winrar, then you should change the association to javaw.)
Here is a short working example:
Dummy.java:
Code: Select all
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Dummy
{
public static void main(String[] arg)
{
try {
new DummyFrame().show();
} catch(Exception x) {
x.printStackTrace();
}
}
}
Code: Select all
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DummyFrame extends JFrame implements ActionListener
{
public DummyFrame()
{
setTitle("Dummy");
setSize(320, 240);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
}
}
Code: Select all
Main-Class: Dummy
Code: Select all
javac *.java
jar cmf Manifest.txt runme.jar *.class
- Ali Arman Tamal
- Learning poster
- Posts: 76
- Joined: Sat Jan 15, 2005 5:04 pm
- Location: Dhaka
- Contact:
-
- New poster
- Posts: 2
- Joined: Fri Dec 30, 2005 7:18 pm
hello
I tried to produce the jar file with the given example. I put the Dummy.java and DummyFrame.java in one folder and also the manifest file in the same folder. Then i applied the command given in that folder path. The jar file was created without any error.
But when i double click to run it (jar file) it says :
"cannot find the main class - program will now exit "
can anyone help me
I tried to produce the jar file with the given example. I put the Dummy.java and DummyFrame.java in one folder and also the manifest file in the same folder. Then i applied the command given in that folder path. The jar file was created without any error.
But when i double click to run it (jar file) it says :
"cannot find the main class - program will now exit "
can anyone help me