How can i run this program from a jar.

Reply

Join Date: Aug 2005
Posts: 75
Reputation: Sailor_Jerry is an unknown quantity at this point 
Solved Threads: 2
Sailor_Jerry's Avatar
Sailor_Jerry Sailor_Jerry is offline Offline
Junior Poster in Training

How can i run this program from a jar.

 
0
  #1
Aug 23rd, 2006
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?

  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
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 871
Reputation: vinod_javas is an unknown quantity at this point 
Solved Threads: 7
vinod_javas's Avatar
vinod_javas vinod_javas is offline Offline
Practically a Posting Shark

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

 
0
  #2
Feb 22nd, 2007
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
Adios,

Vinod......
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

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

 
0
  #3
Feb 22nd, 2007
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.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 1
Reputation: haleemsl is an unknown quantity at this point 
Solved Threads: 0
haleemsl haleemsl is offline Offline
Newbie Poster

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

 
0
  #4
May 1st, 2008
Thank you for this was helpful to me.
But I tried like
Java -jar blpack.jar 
like you said but it giving error
Failed to load Main-Class manifest attribute from blpack.jar
Please any body help me? I used Eclipse3.2.2
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 3,584
Reputation: jasimp has a spectacular aura about jasimp has a spectacular aura about jasimp has a spectacular aura about 
Solved Threads: 52
Featured Poster
jasimp's Avatar
jasimp jasimp is offline Offline
Senior Poster

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

 
0
  #5
May 2nd, 2008
How to make a Jar File I used this to learn how. The author explains it very well.
"Argyou not with the hand you are dealt in cards or life." ---- Wizard and Glass
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC