Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I feel dumb: How can I get my java apps (not applets!) to run by double-clicking it in windows explorer environment?
I have my set path variable correct (C:\j2sdk1.4.0_02\bin) b/c I can run the apps no problem from the dos prompt (with standard "java MyClass" command). So how do I get it to run by just double-clicking the icon the way you do most Windows apps? Must be simple but...?

In explorer, go to the menu bar and find the item "Folder Options...".
Go there and select the file type tab. Then click new type, set the extension to class, click new. There you can type the text that will appear in the popup menu when the file is right-clicked, and you can set the path to the program that the file will use. To have it open that program when the file is double-clicked, click set default. (If you want to have an access key in the pop up menu, put and ampersand (&) before the character that you wish to use.

Thanks a lot for responding Chad.
But I don't think that's what's needed. I don't want to open my class files with an application, rather, I want my class files to simply run when double-clicked. I think what you're talking about is how to get a particular application to open a particular file type. (E.g., you get Word to open .doc file types in the way you described.) I don't think that's what's needed here. We want the class file to run, not open, when clicked.
Make sense? I could definitely be missing something here--if so please set me straight!
Cheers

Paul-
The problem is that class files are not, by themselves, executable. They need to be run in the Java runtime environment, which you invoke when you type "java myClass". This runs the java runtime environment with myClass as a parameter. The runtime environment then finds myClass and executes it.I do not have the runtime environment installed on this computer anymore or I would play around and find a solution, but hopefully this will be a starting off point.
Note that several people on this forum have asked how to change a class to an exe, and there are programs that can do that...here are two links that somebody gave in response to that question (feel free to do a search yourself if this will fit your needs...but I have a feeling it won't.)
http://gcc.gnu.org/java/http://www.devdaily.com/java/edu/qanda/pjqa00004.shtml
Good luck,
SN

SN,
You're right. I figured out basically what's needed: You have to "jar" your class file, i.e., turn it into a MyClass.jar file by using the java jar tool. Then you can associate that file type with the "Jar Executable File" selection in the list of programs in the "File Type" tab.
Thanks for your response--I appreciate the effort; the sun forum has threads on this stuff that got me going in the right direction.
Cheers,

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |