Page 1 of 1

A newbie question :-)

Posted: Tue Dec 13, 2005 7:15 am
by Ali Arman Tamal
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 :D

Ali Arman Tamal

Posted: Tue Dec 13, 2005 4:04 pm
by chunyi81
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.

Posted: Tue Dec 13, 2005 4:15 pm
by Ali Arman Tamal
You misunderstood me :-?

I wanted to know is it possible to run java programs with the console

thanks :)

Posted: Tue Dec 13, 2005 4:21 pm
by Cho
The jar utility may be what you are looking for:

Here is a short working example:

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) {

Code: Select all

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class DummyFrame extends JFrame implements ActionListener
   public DummyFrame()
      setSize(320, 240);
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
   public void actionPerformed(ActionEvent e)

Code: Select all

Main-Class: Dummy
Run these two commands:

Code: Select all

javac *.java
jar cmf Manifest.txt runme.jar *.class
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.)

Posted: Tue Dec 13, 2005 4:43 pm
by Ali Arman Tamal
Thanks a lot !
I've found my answer :D :D :D

Posted: Fri Dec 30, 2005 7:44 pm
by HolyMoly!!!
hello :D

I tried to produce the jar file with the given example. I put the and 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 :(

JAR files

Posted: Sun Jan 01, 2006 11:29 am
by MAK
Make sure you have included the name of your driver class in the manifest file. The driver class should have have the main method.