Martin O
May 18th, 2007, 11:40 AM
I'm having problems running a java class with javaw in a Windows shortcut. I'm getting:
'Could not find the main class. Program will exit.'
I re-read this forum's FAQ. I wanted to tryout what was mentioned here (from the FAQ):
Eliminate Prompt and Executable Jars
Javaw.exe is intended to run Java programs, just like java.exe, but without the Consol Window.
Suppose you wanted to run a Java program in a Windows Environment, you could create a shortcut to
your program, and the command to run your program would be "javaw myProject.MyProgram"
I can't get this to work. First, when he mentions 'java program' does he mean the .class file? Or do I need to put the class in a jar for this to work?
I created a test gui app. I didnt create a jar or put it in a package. I can run this from the cmd prompt with 'java Test'. I then right clicked on the class file, chose 'Copy', then 'Paste Shortcut'. This creates a shortcut in the same folder as my Test.class file. I then right clicked the shortcut, chose 'Properties', then replaced the Target line:
C:\Martin\Programming\testjavaw\Test.class
with
javaw C:\Martin\Programming\testjavaw\Test.class
The shortcuts 'Start In' was set to 'C:\Martin\Programming\testjavaw' -- I didnt change that.
Does anyone know what I did wrong?
btw, I also tried this which gave me the same thing:
javaw -cp .;C:\Martin\Programming\testjavaw C:\Martin\Programming\testjavaw\Test.class
Thanks
'Could not find the main class. Program will exit.'
I re-read this forum's FAQ. I wanted to tryout what was mentioned here (from the FAQ):
Eliminate Prompt and Executable Jars
Javaw.exe is intended to run Java programs, just like java.exe, but without the Consol Window.
Suppose you wanted to run a Java program in a Windows Environment, you could create a shortcut to
your program, and the command to run your program would be "javaw myProject.MyProgram"
I can't get this to work. First, when he mentions 'java program' does he mean the .class file? Or do I need to put the class in a jar for this to work?
I created a test gui app. I didnt create a jar or put it in a package. I can run this from the cmd prompt with 'java Test'. I then right clicked on the class file, chose 'Copy', then 'Paste Shortcut'. This creates a shortcut in the same folder as my Test.class file. I then right clicked the shortcut, chose 'Properties', then replaced the Target line:
C:\Martin\Programming\testjavaw\Test.class
with
javaw C:\Martin\Programming\testjavaw\Test.class
The shortcuts 'Start In' was set to 'C:\Martin\Programming\testjavaw' -- I didnt change that.
Does anyone know what I did wrong?
btw, I also tried this which gave me the same thing:
javaw -cp .;C:\Martin\Programming\testjavaw C:\Martin\Programming\testjavaw\Test.class
Thanks