[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how to make executable jar

Posted on 2013-01-11
5
Medium Priority
?
516 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 1020 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

656 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