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 in Jdk 1.7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "jar in Jdk 1.7" Watch "jar in Jdk 1.7" New topic
Author

jar in Jdk 1.7

Khushdeep Singh
Greenhorn

Joined: Jan 31, 2012
Posts: 6
How run jar file using jdk 1.7. and When i run simple program HelloWorld.java run through command-prompt then compiler show at runtime could not load main class. Tell me solution.

Thanks in advance
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14431
    
  23

Welcome to the Ranch.

Please show us your code and tell us the exact commands that you are using to compile and run your application. Right now you haven't given us enough details to tell you exactly what's wrong.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Khushdeep Singh
Greenhorn

Joined: Jan 31, 2012
Posts: 6
Sir, My old jar file which i created through Eclipse and netbean and new created jar files not run. but code is running in eclipse and netbean.

When i click on created jar file . then it generate pop window which show error: unable to launch application.


when i click on details then it show....

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)
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Khushdeep Singh wrote:How run...


Please don't abuse colors like that.

It makes your post hard to read. Only use color sparingly for highlighting or correlating small amounts of text.

Thanks!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Jeff Verdegan wrote: . . . Please don't abuse colors like that. . . .
I have got rid of the green from the text.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
And what is in the manifest file in your .jar?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14431
    
  23

Are you trying to run the application as a Java Web Start application?
Khushdeep Singh
Greenhorn

Joined: Jan 31, 2012
Posts: 6
My manifest file contain....

Manifest-Version: 1.0
Class-Path: . Reader_lib/poi-3.7-20101029.jar Reader_lib/itextpdf-5.1.
3.jar
Main-Class: DateReaderMain

where DateReaderMain is main class.


and i run this application as Java Application.

This application work in eclipse. but when i create jar file of this application through eclipse but jar file not working. Even my old jar files which working on old version of jdk 1.6 . but not working on jdk 1.7.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14431
    
  23

What is the exact command that you are typing in on the command prompt to start the application?

Is your DateReaderMain class not in a package?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
. . . and I presume by the blank line in your post that you have a blank line at the end of the manifest file; that blank line is necessary.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14431
    
  23

The stack trace that you posted indicates that you're trying to run the application via Java Web Start.

Khushdeep Singh wrote: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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jar in Jdk 1.7