Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I execute class in .jar file from command line?

843785Nov 6 2008 — edited Nov 6 2008
My apologies for posting such a dreadfully newbie question. I have a Java .jar which, when I examine it with jarbrowser, contains a number of classes. This .jar, it should be added, was not written by me. Under normal circumstances, it seems to be called by an XML file in order to populate metrics on a webpage. I would very much like to be able to execute the java directly from the bash command prompt - but all my attempts so far have been to no avail.

The xml is like this:
		<task id="metrics.mem" menu_id="metrics.menu" order="0">
			<resource>com.45rpm.met.metrics</resource>
			<display_key>metrics_memory</display_key>
			<class>com.45rpm.met.memorycheck</class>
			<template browser="default">metrics.metrics_memory</template>
			<required_role>console</required_role>
		</task>
		<task id="metrics.cpu" menu_id="metrics.menu" order="1">
			<resource>com.45rpm.met.MineResource</resource>
			<display_key>metrics_cpu</display_key>
			<class>com.45rpm.met.cpucheck</class>
			<template browser="default">metrics.metrics_cpu</template>
			<required_role>console</required_role>
		</task>
I have tried to execute the java in umpteen ways, with both java and (quite aware that this might be a dirty word) gij. The most successful attempts have elicited the following response:
java -jar metrics.jar com.45rpm.met.memorycheck
Failed to load Main-Class manifest attribute from
metrics.jar
I'm sorry to bother you all with such a trivial issue - but searching Google hasn't helped me so far, and I could really use a hand!

By the way, I should add that I have obfuscated what the actual metrics are - I'm quite aware that checking memory on Unix boxes does not require a trip to Javaland.

Edited by: 45RPMSoftware on Nov 6, 2008 6:59 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2008
Added on Nov 6 2008
7 comments
693 views