Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to access jar file

 
Talitha Bell
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:\>
 
Joe Ess
Bartender
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20510
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be better to use quotes, so you can have spaces in the path:

Using the full path:
 
Talitha Bell
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
Joe Ess and Rob Prime for reply

Rob formula works fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic