944,202 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 13805
  • Java RSS
Aug 23rd, 2006
0

How can i run this program from a jar.

Expand Post »
I am using IBM Websphere, and from here i can just click Run As java application, and the program runs inside websphere. But i want to run the program outside IDE.

I created a jar file and everthing is correct with it. It has the MANIFEST.MF and all.

So what do i need to do to run this from cmd.exe? I would like cmd to open when the jar file is double clicked so that the program will use the command line as the input?

Java Syntax (Toggle Plain Text)
  1. import java.io.*; // Java I/O classes
  2. public class L3P3
  3. {
  4. public static void main(String []arg) throws IOException // throws IOException
  5. {
  6. BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
  7.  
  8. System.out.println("Enter in your full name");
  9. String s1 = input.readLine();
  10. StringBuffer tmp = new StringBuffer(s1);
  11. String s2 = tmp.reverse().toString();
  12.  
  13. System.out.println("Your reversed name is " + "\"" + s2 + "\"");
  14. }
  15. }

Thanks, sj
Similar Threads
Reputation Points: 13
Solved Threads: 2
Junior Poster in Training
Sailor_Jerry is offline Offline
88 posts
since Aug 2005
Feb 22nd, 2007
0

Re: How can i run this program from a jar.

if u want to run ur jar from cmd means just run like this just go to ur file location through cmd and then type

javaw -jar filename.jar

or
java -jar filename .jar

main thing is your OS should hav JVM otherwise jar file wont run
Reputation Points: 119
Solved Threads: 7
Practically a Posting Shark
vinod_javas is offline Offline
871 posts
since Feb 2007
Feb 22nd, 2007
0

Re: How can i run this program from a jar.

ur has nothing to do with it. Java didn't exist when people were living there.

to make an executable jar, you need to provide the Main-Class attribute in the manifest file inside the jar.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
May 1st, 2008
0

Re: How can i run this program from a jar.

Thank you for this was helpful to me.
But I tried like
Java -jar blpack.jar 
like you said but it giving error
Quote ...
Failed to load Main-Class manifest attribute from blpack.jar
Please any body help me? I used Eclipse3.2.2
Reputation Points: 10
Solved Threads: 0
Newbie Poster
haleemsl is offline Offline
1 posts
since May 2008
May 2nd, 2008
0

Re: How can i run this program from a jar.

How to make a Jar File I used this to learn how. The author explains it very well.
Featured Poster
Reputation Points: 533
Solved Threads: 53
Senior Poster
jasimp is offline Offline
3,593 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Inserting a Data Grid
Next Thread in Java Forum Timeline: java code





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC