Skip to main content

how can i execute a jar file???(another topic about jar files....)

1 reply [Last post]
Joined: 2006-08-01

I try to run my jar files and i take msg like above:
C:\Documents and Settings\Christina>java -jar tools.jar
Unable to access jarfile tools.jar
What i should do???


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-08-07

Well I guessed you fixed this by now.

You may get the above error if:
- 'tools.jar' is not in the current working directory (since you have provided a relative path)
- no main class is defined by the jar file (cf. java tutorial for defining manifest files and declaring main class in definition of jar files)

If you do not wish to define a main class, then you want to use -cp, rather than -jar, to put the jar on the classpath

java -cp MY_JAR_FILE.jar HelloWorld