unable to make executable jar file

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 3481 Views - Last Post: 02 March 2011 - 11:02 PM Rate Topic: -----

#1 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

unable to make executable jar file

Posted 02 March 2011 - 08:17 AM

i want to make an executable jar file and i followed this process

Quote

Creating an Executable Jar File:

1)Start Command Prompt.

2)Navigate to the folder that holds your class files:
C:\>cd \mywork

3)Set path to include JDK’s bin. For example:
C:\mywork> path c:\Program Files\Java\jdk1.5.0_09\bin;%path%

4)Compile your class(es):
C:\mywork> javac *.java

5)Create a manifest file:
C:\mywork> echo Main-Class: DanceStudio >manifest.txt

6)Create a jar file:
C:\mywork> jar cvfm DanceStudio.jar manifest.txt *.class


but i was unable to make it...when i do

jar cvfm myjar.jar manifest.mft *.class

it shows
added manifest
adding: Chart.class(in = 7239) (out= 3535)(deflated 51%)
adding: frame.class(in = 2422) (out= 1337)(deflated 44%)
adding: Result.class(in = 1417) (out= 780)(deflated 44%)
adding: WinBulb.class(in = 2151) (out= 1073)(deflated 50%)
adding: WinGey.class(in = 2587) (out= 1300)(deflated 49%)
adding: WinHeat.class(in = 2593) (out= 1300)(deflated 49%)
adding: WinterComp$1.class(in = 692) (out= 423)(deflated 38%)
adding: WinterComp$2.class(in = 691) (out= 422)(deflated 38%)
adding: WinterComp$3.class(in = 692) (out= 422)(deflated 39%)
adding: WinterComp$4.class(in = 692) (out= 423)(deflated 38%)
adding: WinterComp.class(in = 5765) (out= 2757)(deflated 52%)
adding: WinTube.class(in = 2591) (out= 1300)(deflated 49%)


but when i do
java -jar myjar.jar it gives me error
Exception in thread "main" java.lang.NoClassDefFoundError: frame (wrong name: Ne
w2/frame)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: frame. Program will exit.


i am ready to attach file containing my java files, class files, jpeg and manifest file

pls help me or if u can make me a jar file it would be very grateful

Is This A Good Question/Topic? 0
  • +

Replies To: unable to make executable jar file

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,021
  • Joined: 15-July 08

Re: unable to make executable jar file

Posted 02 March 2011 - 08:37 AM

You are trying to find the frame class in the wrong package:
New2/frame

It's looking fro frame in the New22 package. However, that package does not exist. Either change the namespace reference or add the folder (New2) to the JAR instead of *.class.
Was This Post Helpful? 0
  • +
  • -

#3 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

Re: unable to make executable jar file

Posted 02 March 2011 - 08:51 AM

View PostDogstopper, on 02 March 2011 - 03:37 PM, said:

You are trying to find the frame class in the wrong package:
New2/frame

It's looking fro frame in the New22 package. However, that package does not exist. Either change the namespace reference or add the folder (New2) to the JAR instead of *.class.

thanks for prompt reply...can you pls tell me how to do that ???
Was This Post Helpful? 0
  • +
  • -

#4 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,021
  • Joined: 15-July 08

Re: unable to make executable jar file

Posted 02 March 2011 - 08:53 AM

Can you post your manifest file?
Was This Post Helpful? 0
  • +
  • -

#5 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

Re: unable to make executable jar file

Posted 02 March 2011 - 09:54 AM

i have just written this:

Main-Class: frame



Was This Post Helpful? 0
  • +
  • -

#6 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2870
  • View blog
  • Posts: 11,021
  • Joined: 15-July 08

Re: unable to make executable jar file

Posted 02 March 2011 - 10:00 AM


Main-Class: frame.class


Was This Post Helpful? 0
  • +
  • -

#7 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

Re: unable to make executable jar file

Posted 02 March 2011 - 10:04 AM

View PostDogstopper, on 02 March 2011 - 05:00 PM, said:


Main-Class: frame.class




again its giving an error

Quote

Exception in thread "main" java.lang.NoClassDefFoundError: frame/class
Caused by: java.lang.ClassNotFoundException: frame.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: frame.class. Program will exit.


btw, all the java files belong to package New2
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: unable to make executable jar file

Posted 02 March 2011 - 06:44 PM

And it is

jar -cvfm DanceStudio.jar manifest.txt *.class

not

jar cvfm DanceStudio.jar manifest.txt *.class

View Postsahildave1991, on 02 March 2011 - 12:04 PM, said:

btw, all the java files belong to package New2

so should be

Main-Class: New2/frame.class

and by the way, by convention:
- package name are all lowercase so should be new2
- class name should start with an uppercase character so should be Frame
Was This Post Helpful? 0
  • +
  • -

#9 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

Re: unable to make executable jar file

Posted 02 March 2011 - 10:13 PM

View Postpbl, on 03 March 2011 - 01:44 AM, said:

And it is

jar -cvfm DanceStudio.jar manifest.txt *.class

not

jar cvfm DanceStudio.jar manifest.txt *.class

View Postsahildave1991, on 02 March 2011 - 12:04 PM, said:

btw, all the java files belong to package New2

so should be

Main-Class: New2/frame.class

and by the way, by convention:
- package name are all lowercase so should be new2
- class name should start with an uppercase character so should be Frame



Thanks, i did -cvfm only, that i knew...and thanks again for telling me that naming convention, i'll keep it in mind in the future...but still i am not able to make jar file
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: unable to make executable jar file

Posted 02 March 2011 - 10:20 PM

View Postsahildave1991, on 03 March 2011 - 12:13 AM, said:

but still i am not able to make jar file

What does that mean ? You have problem executing the jar command ?
If it is not the case show the output of

> jar tf DanceStudio.jar
Was This Post Helpful? 0
  • +
  • -

#11 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

Re: unable to make executable jar file

Posted 02 March 2011 - 10:33 PM

View Postpbl, on 03 March 2011 - 05:20 AM, said:

View Postsahildave1991, on 03 March 2011 - 12:13 AM, said:

but still i am not able to make jar file

What does that mean ? You have problem executing the jar command ?
If it is not the case show the output of

> jar tf DanceStudio.jar


see the description in the question...

the jar file is formed without error...but when i run it by

java -jar myjar.jar

it gives error
Exception in thread "main" java.lang.NoClassDefFoundError: frame (wrong name: Ne
w2/frame)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: frame. Program will exit.


Was This Post Helpful? 0
  • +
  • -

#12 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: unable to make executable jar file

Posted 02 March 2011 - 10:38 PM

So re-post your manifest and frame.java
Was This Post Helpful? 0
  • +
  • -

#13 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

Re: unable to make executable jar file

Posted 02 March 2011 - 10:41 PM

View Postpbl, on 03 March 2011 - 05:38 AM, said:

So re-post your manifest and frame.java


According to Dogstopper i made my manifest.mft file like this
Main-Class: frame.class




and my frame.java is like this

package New2;

import java.awt.event.*;
import java.awt.*;

import javax.swing.*;

public class frame extends JFrame

{
	JPanel mainpanel = new JPanel();
	
	JSeparator vertical1 = new JSeparator(JSeparator.VERTICAL);
	JSeparator vertical2 = new JSeparator(JSeparator.VERTICAL);
	JSeparator horizontal1 = new JSeparator(JSeparator.HORIZONTAL);
	JSeparator horizontal2 = new JSeparator(JSeparator.HORIZONTAL);
	
	JLabel note1 = new JLabel();
	JLabel note2 = new JLabel();
	JLabel note3 = new JLabel();
	JLabel head1 = new JLabel();
	JLabel head2 = new JLabel();
	JLabel head3 = new JLabel();
	
	
	
	public frame()
	{
		mainpanel.setLayout(null);
		
		note1.setText("NOTE: Click on the button to activate the controls.");
		note1.setFont(new Font ("Tohoma", 2, 12));
		note2.setText("NOTE: Click on the button to activate the controls.");
		note2.setFont(new Font ("Tohoma", 2, 12));
		note3.setText("NOTE: Click on the button to activate the controls.");
		note3.setFont(new Font ("Tohoma", 2, 12));
		
		head1.setText("Nov, Dec, Jan, Feb");
		head1.setFont(new Font ("Tohoma", 3, 16));
		head2.setText("Mar, Apr, May, Jun");
		head2.setFont(new Font ("Tohoma", 3, 16));
		head3.setText("Jul, Aug, Sept, Oct");
		head3.setFont(new Font ("Tohoma", 3, 16));
		
		note1.setBounds(20,300,350,25);
        note2.setBounds(20,620,350,25);
        note3.setBounds(520,300,350,25);
        head1.setBounds(150,5,350,25);
        head2.setBounds(150,345,350,25);
        head3.setBounds(670,5,350,25);
        
        horizontal1.setBounds(0, 340, 490, 2);
		horizontal2.setBounds(490, 340, 490, 2);
		vertical1.setBounds(490, 0, 2, 350);
		vertical2.setBounds(490, 350, 2, 350);
		
		
		
		add(mainpanel);
		mainpanel.add(note1);
        mainpanel.add(note2);
        mainpanel.add(note3);
        mainpanel.add(head1);
        mainpanel.add(head2);
        mainpanel.add(head3);
        
        mainpanel.add(horizontal1);
		mainpanel.add(horizontal2);
		mainpanel.add(vertical1);
		mainpanel.add(vertical2);
		
		WinterComp objcomp = new WinterComp(mainpanel);
		Result objresult = new Result(mainpanel);
	}
	
	public static void main(String[] args) 
	{
		frame obj = new frame();
		obj.setSize(1000,700);
		obj.setVisible(true);
		obj.setDefaultCloseOperation(EXIT_ON_CLOSE);	
	}

}



Was This Post Helpful? 0
  • +
  • -

#14 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: unable to make executable jar file

Posted 02 March 2011 - 10:45 PM

See my poost #8

Your package is New2 so in the manifest file the class is New2/frame.class
Was This Post Helpful? 0
  • +
  • -

#15 sahildave1991  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 45
  • Joined: 18-September 10

Re: unable to make executable jar file

Posted 02 March 2011 - 10:52 PM

View Postpbl, on 03 March 2011 - 05:45 AM, said:

See my poost #8

Your package is New2 so in the manifest file the class is New2/frame.class


i did Main-Class: New2/frame.class

but it gave me error again!

C:\Users\Sahil\Downloads\java\New folder>jar -cvfm myjar.jar manifest.mft *.class
added manifest
adding: Chart.class(in = 7251) (out= 3547)(deflated 51%)
adding: frame.class(in = 2422) (out= 1337)(deflated 44%)
adding: Result.class(in = 1417) (out= 781)(deflated 44%)
adding: WinBulb.class(in = 2151) (out= 1073)(deflated 50%)
adding: WinGey.class(in = 2587) (out= 1300)(deflated 49%)
adding: WinHeat.class(in = 2593) (out= 1300)(deflated 49%)
adding: WinterComp$1.class(in = 692) (out= 423)(deflated 38%)
adding: WinterComp$2.class(in = 691) (out= 422)(deflated 38%)
adding: WinterComp$3.class(in = 692) (out= 422)(deflated 39%)
adding: WinterComp$4.class(in = 692) (out= 421)(deflated 39%)
adding: WinterComp.class(in = 5765) (out= 2754)(deflated 52%)
adding: WinTube.class(in = 2591) (out= 1300)(deflated 49%)

C:\Users\Sahil\Downloads\java\New folder>java -jar myjar.jar
Exception in thread "main" java.lang.NoClassDefFoundError: New2/frame/class
Caused by: java.lang.ClassNotFoundException: New2.frame.class
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: New2/frame.class. Program will exit.


Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2