Solved

how to make executable jar

Posted on 2013-01-11
5
497 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

734 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