Results 1 to 4 of 4
Thread: running java under Windows 7
- 05-29-2010, 07:31 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
running java under Windows 7
This may be a Windows 7 problem and have nothing to do with Java ... so let me apologize from the start!
I have been writing all my Java programs on a Mac. Once the program is compiled, an icon associated with the main class appears. If I click the icon, the program runs swimmingly.
When I try to run the same program under Windows 7 by clicking on the main class file, Windows 7 asks, "Which program do you want to open the file with?" If I select Java, I get a spinning circle ... kind of like my program going down the toilet ... and the program never runs.
I can compile and run the program from the command prompt.
Is there some arcane Windows trick I must employ to get the program to run just by clicking the icon?
- 05-29-2010, 07:37 PM #2
Senior Member
- Join Date
- May 2010
- Posts
- 436
- Rep Power
- 4
You may need to set your Window file associations so that class files are associated with java (or is it javaw?). This can be done via the Windows control panel (I think).
- 05-29-2010, 08:19 PM #3
Can you open a command prompt window and change to the folder with the class file? If so you can then issue the java command:
java filename (note without the .class extension)
There is a problem with trying to associate a .class file with a command. You'll need to do some tricks to strip off the .class extension.
I (just now in fact) wrote a small batch file that strips off the extension. I then associate that batch file with the .class extension:
Action: C:\Batchfiles\ExecClass.bat "%1"
ExecClass.bat:If anyone knows a cleaner way to execute a java .class file, please post it.REM Execute a java class file - need to strip extension
echo filename is %~n1
java %~n1
MORE
If you package your code in a .jar file, there shouldn't be a problem. The jre/jdk install adds an association for the .jar extension.Last edited by Norm; 05-29-2010 at 09:34 PM. Reason: correct spelling error
- 05-29-2010, 08:36 PM #4
Member
- Join Date
- Nov 2009
- Posts
- 90
- Rep Power
- 0
Similar Threads
-
Errors running app in linux but not in Windows
By JohnST in forum New To JavaReplies: 3Last Post: 03-12-2010, 01:58 AM -
java on windows 64
By JoelOFH in forum New To JavaReplies: 1Last Post: 01-27-2010, 06:27 AM -
Java IDE for windows 7
By Implode in forum New To JavaReplies: 3Last Post: 09-17-2009, 08:16 AM -
Problem in running Java swing wizard in jre 1.6 while it is running in jre 1.4
By Sanjay Dwivedi in forum AWT / SwingReplies: 0Last Post: 08-26-2009, 01:03 PM -
Help with windows in java
By lenny in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 06:22 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks