Solved

how to make executable jar

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

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 17

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

690 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