I've seen questions regarding this problem posted in many places, but no solution that works for me. I have the problem simplified so maybe we can get a solution:
The error ("could not find the main class") ocurrs only on machines with just
a jre (no jdk installed) from the following command when using Start->Run:
javaw -jar c:/trunk/dev/java/test/jartest.jar
BUT,
The error does not occur when using java instead of javaw.
ALSO,
BOTH ways of running work fine on a machine with the jdk installed.
I have the following simple code:
//----------
import javax.swing.JOptionPane;
public class jartest
{
public jartest()
{
JOptionPane.showMessageDialog(null, "hey", "jartest", JOptionPane.INFORMATION_MESSAGE);
}
public static void main( String args[] )
{
jartest jt = new jartest();
}
}
//---------- end of file
--------------------
my environment is WindowsXP Pro
$ java -version
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)
javac -version
javac 1.5.0_02
javac: no source files
....
--------------------
I build my jar file as follows:
javac -d . jartest.java
jar cfm jartest.jar mainFile *.class
--------------------
My mainFile is simple:
Main-Class: jartest
--------------------
the client environment is WindowsXp Pro
$ java -version
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)
--------------------
Why does this happen and what is the solution?
The error ("could not find the main class") ocurrs only on machines with just
a jre (no jdk installed) from the following command when using Start->Run:
javaw -jar c:/trunk/dev/java/test/jartest.jar
BUT,
The error does not occur when using java instead of javaw.
ALSO,
BOTH ways of running work fine on a machine with the jdk installed.
I have the following simple code:
//----------
import javax.swing.JOptionPane;
public class jartest
{
public jartest()
{
JOptionPane.showMessageDialog(null, "hey", "jartest", JOptionPane.INFORMATION_MESSAGE);
}
public static void main( String args[] )
{
jartest jt = new jartest();
}
}
//---------- end of file
--------------------
my environment is WindowsXP Pro
$ java -version
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode)
javac -version
javac 1.5.0_02
javac: no source files
....
--------------------
I build my jar file as follows:
javac -d . jartest.java
jar cfm jartest.jar mainFile *.class
--------------------
My mainFile is simple:
Main-Class: jartest
--------------------
the client environment is WindowsXp Pro
$ java -version
java version "1.5.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)
--------------------
Why does this happen and what is the solution?