Solved

how to make executable jar

Posted on 2013-01-11
5
487 Views
Last Modified: 2013-02-28
how to make executable jar for this progam for the below class.

jar cfm app.jar manifest.txt *.class
java.io.FileNotFoundException: manifest.txt (The system cannot find the file specified)
        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:150)
        at sun.tools.jar.Main.main(Main.java:1149)

public static void main(String[] args) {
		PasswordEncryption enc = new PasswordEncryption();
	 
	      System.out.print("Enter your password to be encrpyted: ");

	      //  open up standard input
	      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	      String encrptPass = null;
	      String input = null;

	      try {
	    	   input = br.readLine();
	           encrptPass =enc.encode(input);
	      } catch (IOException ioe) {
	         System.out.println("IO error trying to read your password!");
	         System.exit(1);
	      }
	
	   }

Open in new window

0
Comment
Question by:chaitu chaitu
  • 2
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
yats earned 340 total points
ID: 38766791
you are missing the below step:
C:\mywork> echo Main-Class: DanceStudio >manifest.txt
C:\mywork> jar cvfm DanceStudio.jar manifest.txt *.class

Refer the below tutorial:
http://www.skylit.com/javamethods/faqs/createjar.html
0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 38766845
D:\Work>echo Main-Class: PasswordEncryption >manifest.txt

D:\Work>jar cvfm app.jar manifest.txt *
added manifest
adding: com/(in = 0) (out= 0)(stored 0%)
adding: com/util/PasswordEncryption.class(in = 2257) (out= 1206)(d
adding: manifest.txt(in = 33) (out= 33)(deflated 0%)

D:\Work>execute.bat

D:\Work>java -jar app.jar
Exception in thread "main" java.lang.NoClassDefFoundError: PasswordEncryption
Caused by: java.lang.ClassNotFoundException: PasswordEncryption
        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: PasswordEncryption . Program will exit.

D:\Work>

Open in new window

0
 
LVL 20

Author Comment

by:chaitu chaitu
ID: 38766864
when i run

D:\Work>app.jar

Could not find Main class..
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 38767267
You've got to remember the carriage return too,which must always go after the last line in any manifest.
0
 
LVL 16

Expert Comment

by:krakatoa
ID: 38768401
BTW chiatuu - how impecunious are you in reality? How do you arrive at 340 points for this question, when you have unlimited tokens in the bank this month? :/\
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HSSFWorkbook cannot be resolved error 10 71
Java Timer (static) 9 45
netstat -ano | find "8000" and taskkill /f /pid 2984 3 57
mysql jsp example issue 32 38
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question