Click to See Complete Forum and Search --> : Running a program with javaw & a Windows shortcut


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

Martin O
May 18th, 2007, 11:55 AM
Solved it :o

First I had to take the .class out of:

javaw C:\Martin\Programming\testjavaw\Test.class

Still didnt work. Then I changed it to

javaw Test

And it worked.

:o

Rakhitha
May 21st, 2007, 11:32 PM
In order for abov to work there are lots of things that has to fall in to place.

The normall practis is crearte a .cmd file with the command to run the java program and then set the shortcut to that cmd file.

Martin O
May 22nd, 2007, 10:30 AM
Oh ok. Thanks Rakhitha :)