wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes .jar shortcut in windows??? an easy question im sure... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ".jar shortcut in windows??? an easy question im sure..." Watch ".jar shortcut in windows??? an easy question im sure..." New topic
Author

.jar shortcut in windows??? an easy question im sure...

Art Neil
Greenhorn

Joined: Sep 17, 2004
Posts: 11
I have a .jar that I can run through cmd, but i want to create a regular windows shortcut to run it, Im sure this is a simple answer. Any help??

Art
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

Simple. You set up your shortcut to run whatever you put on the command line:

java -jar YourJarFile.jar


Alternatively, you could call:

javaw -jar YourJarFile.jar

(This will produce no command prompt...)

Finally, if you used the installer to install Java on your system (which is likely), then all you have to do is double-click the .jar file; the installer maps the .jar extension to the javaw executable.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Art Neil
Greenhorn

Joined: Sep 17, 2004
Posts: 11
Well, it almost goes when I double click, but I get a failed to load main-class manifest blah blah error.

Works fine from cp. I tried adding the command line attributes to the shortcut, same thing. Heres a copy of my command and also the attributes to make it run in cp. What have I done wrong?

"C:\Documents and Settings\Melissa\Desktop\aol emails\pfcview.jar"
doesnt work

java -cp pfcview.jar PfcViewer
works in cp only
[ October 12, 2004: Message edited by: Art Neil ]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You can make the JAR file itself runnable by following a few steps:

First, create a text file called "manifest.txt". Actually the file name doesn't matter, but this is the name I will use in the rest of the instructions. Add a single line to this file:

(Replace "MyClass" with the actual class name, of course.)

Then create the JAR file:

Again, you should replace "myjar.jar" with the actual name you want and *.java with the actual files to include in the jar.

Once that is done, you can navigate Windows Explorer to the folder that contains the jar and double click on it to run it. You probably create a shortcut by right clicking and selecting "Create Shortcut", but I haven't tried this before.

I hope this helps answer your question.

Keep coding!

Layne


Java API Documentation
The Java Tutorial
Art Neil
Greenhorn

Joined: Sep 17, 2004
Posts: 11
That completely lost me, Im not a coder. Im just trying to use a little java app that has no shortcut and wont run when I dbl click it.
Nigel Browne
Ranch Hand

Joined: May 15, 2001
Posts: 673
If you type jar xvf pfcview.jar on the cp you will receive a listing of the contents of the .jar file. You should look to see if there is a META-INF directory with a manifest file in it. Alternately you can browse .jar files using winzip. If the manifest isn't present, you will need to extract the .jar file and then recreate it, including a manifest file as per Layne's instructions.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

write a pfcview.bat:
------------
cd "C:\Documents and Settings\Melissa\Desktop\aol emails"
javaw -cp pfcview.jar PfcViewer
---------------
run that bat-file.

works in cp only
in cp?


http://home.arcor.de/hirnstrom/bewerbung
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Art Neil:
That completely lost me, Im not a coder. Im just trying to use a little java app that has no shortcut and wont run when I dbl click it.

I'm sorry. I should have clarified if you were packaging the JAR file yourself. Apparently you are using a program written by someone else that is packaged in a JAR, correct? In that case, Stefan's suggestion above should do that trick.

Layne

p.s. Does "cp" mean "command prompt"?
Art Neil
Greenhorn

Joined: Sep 17, 2004
Posts: 11
Heys guys, superior help! Thanks! I did get it working by creating a batch file, worked great. This java stuff is very interesting! Since Ive got the attention of some knowledable guys, let me ask a quick question...

I am interested in Java programming, but from Ive found its incredibly hard to get into a Java training program with no programming experience and even harder to get a Java Coder job with no experience, is this real world fact?

Thanks again.

Art
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I don't know what kind of training program you are referring to, but as for the job, I'm certain that most employers want experience. Many Java Ranchers are learning Java on their own by reading online tutorials and printed books as well as asking questions here. My personal experience with Java started with a semester introduction to the basic syntax and libraries available. I had previous programming experience with other languages, so it wasn't too difficult for me to pick up. For someone without any programming experience, I suspect it will take closer to 6 months or a year to feel comfortable with Java.

If you are interested in learning Java, my suggestion is to find some online tutorials and buy a book. (Suggestions for books have been posted in other threads on many occassions. You can use the Search tool to find these suggestions by clicking the linke towards the top of the page.) Also feel free to post specific questions when you need clarification.

Good luck!

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: .jar shortcut in windows??? an easy question im sure...
 
Similar Threads
Multiple threads not running from jar file
Is it possible to create a windows short cut via ant
Annoying DOS window
Hiding DOS console w/GUI app.
Desktop Shortcut