Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

run java class files by double clicking(urgent)

 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a bat file to invoke the class file. You can double click the bat file.
 
netharam ram
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it can be done as you described. Dirty, thrown together code:
RunClass.java:

Register.reg:
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic