• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

My java .Jar file doesn't launch

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>?
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79701
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
... and welcome to the Ranch
 
Aire sore
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79701
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Let nothing stop you! Not even this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic