Solved

how to make executable jar

Posted on 2013-01-11
5
482 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now