This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Java in General and the fly likes Unable to access jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Unable to access jar file" Watch "Unable to access jar file" New topic

Unable to access jar file

Talitha Bell

Joined: Oct 01, 2007
Posts: 29
Hi All

I tried to access jar file by the command

java -jar JAVA_HOME\demo\jfc\Java2D\Java2Demo.jar from c:\>

but give error [Unable to access jarfile JAVA_HOME\demo\jfc\Java2D\Java2Demo.jar]

i gave the full path instead of JAVA_HOME[C:\Program Files\Java\jdk1.5.0_12] but same problem

but when I tried to access jar file from the directory [C:\Program Files\Java\jdk1.5.0_12\demo\jfc\Java2D]
by command java -jar Java2Demo.jar
it works fine

any one tell me why ,how i will access it from c:\>

Thanks, Talitha
Joe Ess

Joined: Oct 29, 2001
Posts: 9045

You have to tell the command processor you are using an environment variable. On windows, this is done by enclosing the variable in %:

Using the full path:

works for me as well.

[How To Ask Questions On JavaRanch]
Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

It would be better to use quotes, so you can have spaces in the path:

Using the full path:

How To Ask Questions How To Answer Questions
Talitha Bell

Joined: Oct 01, 2007
Posts: 29
Joe Ess and Rob Prime for reply

Rob formula works fine.
I agree. Here's the link:
subject: Unable to access jar file