Executable jar file

S

sc_wizard29

Hi everyone,

I have an executable jar file that lies in c:\lib (yes, I'm on a
windows box)... and I want to execute it from c:\

This jar file contains the following MANIFEST.MF file :

Manifest-Version: 1.0
Created-By: 1.4.2_08 (Sun Microsystems Inc.)
Main-Class: sub1.HelloWorld1

I've tried 3 different ways to execute the jar file :

C:\>java -classpath ".\lib\sub1_exec.jar" sub1.HelloWorld1
HelloWorld1.main() : hello world
C:\jar>java -jar .\lib\sub1_exec.jar
HelloWorld1.main() : hello world
C:\jar>java -classpath ".\lib\sub1_exec.jar" -jar sub1_exec.jar
Unable to access jarfile sub1_exec.jar

Can anyone explain me why the last method doesn't work ? (and what can
I do if I don't want to make it work ?)

Thanks for helping... this stuff is driving me crazy ;-)
 
T

Thomas Kellerer

I've tried 3 different ways to execute the jar file :

C:\>java -classpath ".\lib\sub1_exec.jar" sub1.HelloWorld1
HelloWorld1.main() : hello world
C:\jar>java -jar .\lib\sub1_exec.jar
HelloWorld1.main() : hello world
C:\jar>java -classpath ".\lib\sub1_exec.jar" -jar sub1_exec.jar
Unable to access jarfile sub1_exec.jar

Can anyone explain me why the last method doesn't work ?

Because the -classpath parameter is ignored when you specify -jar

See the description of the -jar parameter at
http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html

Thomas
 
H

hthukral.mickey

"When you use this option, the JAR file is the source of all user
classes, and other user class path settings are ignored"

That was a fast answer... thank you very much !!!

hi

i wnat to some guidance regarding ..from where and how can i learn
programming in java ...any particular Books /refernces ....i'd tried
many so faar..
but not satisfied .
 
A

Andrew Thompson

On Feb 21, 8:19 am, (e-mail address removed) wrote:
...
i wnat to some guidance regarding ..from where and how can i learn
programming in java ...any particular Books /refernces ....i'd tried
many so faar..

Why did you put your question on the end
of this thread that has nothing to do
with books?

It makes more sense to start a new thread
under the subject 'Book recommendations'.

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top