• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to run Java App by a click

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all

How to run the Java apllication by a click on
the .class file ?
I need this Coz I have one java application , But for the
Normal User it will be tedious to type " java appln name "
each time to run the application .
It will be very helpful for me if somebody knows it .
Thanks
Sameer

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
for normal user just give them a .bat file in which u can write
java classfilename
I think this will solve ur problem
bye
pankaj
------------------
SCJP2
 
sameer deshmukh
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Lot Pankaj
Regards
Sameer
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you could go one better and use:
javaw classfilename
Which lets the user close the console window. Its also then possible to create a shortcut to the batch file and get it to close on exit so that the user never sees the console (or only for a second or two).
The latest JREs (1.2.2, 1.3) support double clicking .jar files in Explorer to automatically run them.
Hope that helps.
 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How exactly do you get the batch file to close right away? Which property allows you to do this? (I can't find anything like that in the shortcut properties...)
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just using javaw instead of java to run your classes should do that.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also write a batch file like:
start java FileName
exit
[This message has been edited by mirko carlini (edited March 20, 2001).]
 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is javaw and how is it different from "java classfilename" ?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javaw is Java for Windows. The difference is that it closes the console window once the JVM has been started and the class is loaded.
I personally would accomplish this task by creating a shortcut to javaw.exe and adding the class that I want to execute to the target of the shortcut.
 
ryan burgdorfer
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems that javaw is not closing the console for me...
Here is the contents of my batch file:
<pre><h4>rem Batch file to launch CarTrack
d:
cd java files
javaw CarTrack
exit</h4></pre>
When I double-click on this batch file (or a shortcut pointing to it), the console window stays open just as if I had replaced "javaw" with plain old "java". This behavior is inconsistent with what has been described here...any ideas what is going on?
Although, I am able to close the console window without affecting the java app...
------------------
  • Ryan Burgdorfer
  • Java Acolyte in
  • Columbus, OH USA
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try making a batch file like 1.bat, with the contents
path=c:\jdk1.2\bin;
set classpath=blah....;
java %1
& place it in your system dir(c:\windows\system)
now right click on .class file holding the shift button & click the open with... menu. now choose the file as c:\windows\system\1.bat & then say ok. click the "Always open with the same file" if you want to open all of the .class files with this file(probably you dont want to...). now right clicking the java class file runs it smoothly...
this is ANOTHER way out...

regards,
ptbabu
------------------
 
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Well there is a third party s/w that lets you make java classfiles to exe.. try that coz it lets u put up icons for the exe as well.. but then i guess it wudnt work on ne ting oder dan MS OS..
Regds
Gautham Kasinath
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In windows the default for batch files is to keep the console window open when the batch is completed. It probably displays the message "FINISHED" in the title bar, right? Right-click on your shortcut and go to the Program tab. Under Win9x/Me you will find a check box there that says something like close window when finished. Check that box.
Also, if you read my earlier post, I don't suggest using a batch file. Try what I suggested and see if it doesn't work for you.
 
ryan burgdorfer
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using WinNT4, unfortunately there is no "Program" tab in the shortcut properties.
However, your other suggestion works fine, Bodie. Thanks to you and everyone else for all the ideas!
------------------
  • Ryan Burgdorfer
  • Java Acolyte in
  • Columbus, OH USA
 
reply
    Bookmark Topic Watch Topic
  • New Topic