File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes jar file not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jar file not working" Watch "jar file not working" New topic
Author

jar file not working

linus dale
Ranch Hand

Joined: Jul 01, 2009
Posts: 44

when i double click a jar file that I created,I get this message


An error occurred while launching/running the application.

Category: Launch File Error

The following required field is missing from the launch file: <jnlp>

it opens from command prompt ,but not on double click
please help
thanks
Prashant Hurria
Ranch Hand

Joined: Mar 23, 2009
Posts: 40
Maybe You have the Path and Java Home set in the Commnd prompt but not on the Windows Settings so thats why the error.
Include Java_Home/bin in the Path variable and set Java_home. Will do the trick.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38340
    
  23
More likely you need to associate the file with java.exe. I can't remember how to do it, but on Windows you can set "file associations" that files with extension .xyz open with abdce.exe.
linus dale
Ranch Hand

Joined: Jul 01, 2009
Posts: 44
no, that doesn't seem to work
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38340
    
  23
Anybody else know? I don't. Sorry
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10246
    
    8

Something funny happening here. JNLP file is usually used for JWS. You mention you are double clicking, i.e. the jar file exists on your file system.
1) Can you post the contents of the manifest file (inside the jar)?
2) Also, can you try invoking the jar from the command line (java -jar JarFileName,jar) and provide us the full stack trace?

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
linus dale
Ranch Hand

Joined: Jul 01, 2009
Posts: 44
Maneesh Godbole wrote:Something funny happening here. JNLP file is usually used for JWS. You mention you are double clicking, i.e. the jar file exists on your file system.
1) Can you post the contents of the manifest file (inside the jar)?
2) Also, can you try invoking the jar from the command line (java -jar JarFileName,jar) and provide us the full stack trace?



manifest.txt file is
Main-Class: HelloWorld

from the command line
java -jar JarFileName.jar
the jar file opens and gives the required output
linus dale
Ranch Hand

Joined: Jul 01, 2009
Posts: 44
Maneesh Godbole wrote:Something funny happening here. JNLP file is usually used for JWS. You mention you are double clicking, i.e. the jar file exists on your file system.
1) Can you post the contents of the manifest file (inside the jar)?
2) Also, can you try invoking the jar from the command line (java -jar JarFileName,jar) and provide us the full stack trace?



for another program with 2 classes the jar file doesn't form at all
it is in a different folder jar1

manifest.txt contains
Main-Class: TestII


on doing
jar -cvmf manifest.txt app5.jar *.class
I get

java.io.FileNotFoundException: manifest.txt (The system cannot find the file spe
cified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at sun.tools.jar.Main.run(Main.java:122)
at sun.tools.jar.Main.main(Main.java:903)
program



please help
thanks
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10246
    
    8

It should be manifest.mf.
What you have posted indicates what happens when you build the jar, whereas you initially indicated you already had a jar which was not working.

Please provided answers to the two questions I asked previously. Until we get that information, we would not be able to help you.
linus dale
Ranch Hand

Joined: Jul 01, 2009
Posts: 44
Maneesh Godbole wrote:It should be manifest.mf.
What you have posted indicates what happens when you build the jar, whereas you initially indicated you already had a jar which was not working.

Please provided answers to the two questions I asked previously. Until we get that information, we would not be able to help you.



ok ,now it is working .I was opening it with jawaws instead of javaw in the bin folder
jar files open on double click,but ONLY for programs that have GUI output
manifest.txt as well as manifest.mf, it works for both



Why do jar files for simple(command line output) programs do not open on double click?



all jar files(GUI and non gui) open from command line now
>java -jar filename.jar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jar file not working