aspose file tools*
The moose likes Beginning Java and the fly likes My java .Jar file doesn't launch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "My java .Jar file doesn Watch "My java .Jar file doesn New topic
Author

My java .Jar file doesn't launch

Aire sore
Greenhorn

Joined: Oct 11, 2011
Posts: 3
I'm not sure why, but it runs in the compiler, however it doesn't run as a Jar file.


MissingFieldException[ The following required field is missing from the launch file: <jnlp>]
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


edit:It says that i'm missing a launch file <jnlp> or something, am i suppose to download a random file or can netBean make a <jnlp>?
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
We need details on exactly how you're trying to run it, possibly how you built the jar file if it's your first one.

One way to run a jar file is with a command like "java -jar <jarfilename>". If you do that, I don't know how you'd get an error message that indicates you're somehow running things with the Java Network Launch Protocol (jnlp); it is used for Java Webstart, and is normally thought of as a way to run a java program that is stored on a web page as an application on your own machine.

So how are you doing this?

rc
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
... and welcome to the Ranch
Aire sore
Greenhorn

Joined: Oct 11, 2011
Posts: 3
hmm...I tired running a sample jar file, and it doesn't work either.


//Doc creator

package createblankdocument;
import org.w3c.dom.*;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;






That is just a csv creator.

Anyways i tired using command like http://imageshack.us/photo/my-images/411/abcbl.png/

then it says "'java-jar is not recognized as an internal or external command, operable program or batch file'.

Please help me thanks
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
java is the command

-jar is an option to that command.

You must have a space between "java" and "-jar"; otherwise the command line processor thinks it is all one command. The clue was the message that indicated that "java-jar" was not recognized, that meant that it was treating the two together instead of separately.

rc
Aire sore
Greenhorn

Joined: Oct 11, 2011
Posts: 3
thanks it works now. Just a random question, is this the only way that it could be ran? I was sort of hoping that i could just click the jar file and it open command prompt for me.
Ralph Cook
Ranch Hand

Joined: May 29, 2005
Posts: 479
Well, the answer to your question is no, this isn't the only way to run it. There are two things you can do, assuming you are on Windows.

One is to associate the file type of ".jar" with a program; in this case, the Java SE binary. Look in Windows Explorer (NOT Internet Explorer) under "Tools / Options" and choose the "File Types" panel. Find or create the one for JAR files, and associate it with the Java SE Binary program.

However, that doesn't open a command line window to run the program; keep in mind that many Java programs are GUIs themselves, and don't need and wouldn't want a command line window open just to run them.

So the second thing you can do is create a batch file with the above command in it, then create a shortcut to that command file, and double-clicking that will run your java program. (the command window will then disappear, unless you have other commands in the batch file. Using "pause" is one way to keep it around until you click "Enter", in case there are messages to look at.) If your program is not a GUI, i.e., it outputs to a console and doesn't have SWT or Swing or something for display and control, this is about the only way to do it. You can double-click on it and have it run as above, but it won't show you anything at all -- no error messages, no output, zilch.

rc
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
This assumes there is a link to the class with the main method in the manifest file in the .jar. If it works from the command line, then it should work the other way too. If you use System.console() anywhere, that will return null and you might suffer an Exception.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My java .Jar file doesn't launch