File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes run java class files by double clicking(urgent) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "run java class files by double clicking(urgent)" Watch "run java class files by double clicking(urgent)" New topic
Author

run java class files by double clicking(urgent)

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hai,
How can we execute a java class file in windows by right clicking & using 'sendTo' to a batch file & execute it like an exe file.Also help me how to send command line arguments too from windows environment to run it as I said.We can also run the file by just double clicking by setting the openwith property to the batch file we write.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Write a bat file to invoke the class file. You can double click the bat file.


"JavaRanch, where the deer and the Certified play" - David O'Meara
netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hai Cindy,
I think u have misunderstood my question.I want to run any java class file by double clicking, as we open an ordinary text file in notepad by double clicking it.can u please send me the source code of the batch file,better post it in u'r reply rather than mailing me,so that it helps a lot more than me.
Thank You.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
I don't think that you can set up windows to be able to double click a class file like an exe. You CAN do that with jar files (most window systems come with that pre-defined in the MIME types)
I use WinNT and if I go into Explorer/view/Folder Options/apps and look for Executable Jar File it is defined to start with this command:
C:\Program Files\JavaSoft\JRE\1.4\bin\javaw.exe -jar
with a content_type(MIME) of execution\java.
However if I want to start an application and make an Icon I create a myApp.bat file then in it we set the classpath ind invoke the application with any parameters needed.
http://www.javaranch.com/ubb/Forum34/HTML/000965.html

[This message has been edited by Cindy Glass (edited August 21, 2001).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
IMHO you could do some workaround and create a shortcut that does something like:
c:\jdk1.3\bin\java.exe -classpath <some classpath> SomeClass
as the command line (In Properties)
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Yes it can be done as you described. Dirty, thrown together code:
RunClass.java:

Register.reg:
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
I've updated my java code since the last post, but I noticed something odd. There is a commented out section in the middle. For some reason it isn't needed. I don't know why. Do you?
 
GeeCON Prague 2014
 
subject: run java class files by double clicking(urgent)