954,190 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How can i run this program from a jar.

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?

import java.io.*;	// Java I/O classes
public class L3P3
{
	public static void main(String []arg) throws IOException		// throws IOException
	{
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		System.out.println("Enter in your full name");
		String s1 = input.readLine();
		StringBuffer tmp = new StringBuffer(s1);
		String s2 = tmp.reverse().toString();

		System.out.println("Your reversed name is " + "\"" + s2 + "\"");
	}
}


Thanks, sj

Sailor_Jerry
Junior Poster in Training
88 posts since Aug 2005
Reputation Points: 13
Solved Threads: 2
 

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

vinod_javas
Practically a Posting Shark
871 posts since Feb 2007
Reputation Points: 119
Solved Threads: 7
 

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.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

Thank you for this was helpful to me.
But I tried like

<strong>Java -jar blpack.jar </strong>


like you said but it giving errorFailed to load Main-Class manifest attribute from blpack.jar

Please any body help me? I used Eclipse3.2.2

haleemsl
Newbie Poster
1 post since May 2008
Reputation Points: 10
Solved Threads: 0
 

How to make a Jar File I used this to learn how. The author explains it very well.

jasimp
Senior Poster
3,623 posts since Aug 2007
Reputation Points: 533
Solved Threads: 53
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You