• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble using the jar command

 
Sonny Pondrom
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the java command is used, I get the help data
If the java -version is used, I get the version info
If the jar command is used, I get unknown command.
Why is that?
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm running XP, and I get the same thing. If I include the entire path for jar, then I get the help info. Odd.




Perhaps a Microsoft "feature" for discouraging Java developers? (Not that they'd do such a thing, mind you!)
 
Luis F Garcia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there, Jeff and Sonny !!

I rarely use XP, but I have the PATH and CLASSPATH environment variables set something like this:

PATH=C:\windows\system32;c:\j2sdk1.4.2_05\bin
CLASSPATH=C:\j2sdk1.4.2_05\jre\lib\rt.jar:.

You could do this for every DOS terminal you open by setting them in the System Properties->Advanced Options->Environment Variables.

Hope this helps.

Regards
Luis F
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Luis -

Actually, I already have my path set. I confirmed that by running the "java" and "javac" commands, which are in the same directory as the "jar" command. If the path were not set, the first two commands would not run.

Usually I run all my command line stuff from batch files anyway so that I have copies of my commands handy, so this is the first time I've seen this issue.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's truly bizarre. I'm on XP as well, and when I run java or jar from a random folder, they both work. I have the PATH set just as you do. I'm using 1.4.2_05 though, if that makes a difference.
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have installed the JRE and not the SDK.
The JRE includes the 'java' executable; but not the 'jar' executable.
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Tony -

I don't know who you're addressing, but in case I'm the intended recipient: I have both the SDK installed and the JRE. If I only had the JRE, I could not use the javac command.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David: In which way should it make a difference to use j2sdk1.4.2_05 or j2sdk1.4.2_04?

Jeff: you didn't tell us of your PATH. Perhaps there is a ms-Java installed, which is found, but not your installation?

Luis:
Setting JAVA_HOME isn't a bad idea as well - though unrelated to 'jar not found'.
CLASSPATH=C:\j2sdk1.4.2_05\jre\lib\rt.jar:.

AFAIK you needn't set the classpath to rt.jar - perhaps depending on JAVA_HOME , in your case:
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No MS Java because I would get different version information with the java -version command.

Paths are properly set and working fine except for this one utility.

I agree that it looks and acts like a path problem, but everything else in that directory works. I'm not going to spend any more time on it because I do all my jar/compile/run processing through batch files which use the full pathname because I have to test under multiple or specific compilers or runtime engines.

Thanks for the help though.
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stefan Wagner:
David: In which way should it make a difference to use j2sdk1.4.2_05 or j2sdk1.4.2_04?
I'm not saying that it should make a difference -- just that it might. I've never experienced that problem, though I don't ever jar from the command line, only through Ant.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David: In which way could it make a difference to use j2sdk1.4.2_05 or j2sdk1.4.2_04?
 
David Harkness
Ranch Hand
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stefan Wagner:
David: In which way could it make a difference to use j2sdk1.4.2_05 or j2sdk1.4.2_04?
There could have been an error when packaging 1.4.2_04: maybe they put the "jar" executable in the wrong directory (so it isn't in the path) or misnamed. Unlikely, but that would do it.

I mentioned it so that if someone for whom "jar" doesn't work has the same JDK version, they know to look at their environment before suspecting the JDK.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JRE installations can sometimes override the MS java and javaw in your Windows directory with their own versions.
If that happens (some 1.4 versions do it, some don't I think) you'll end up being able to run java but not javac and jar without setting the path and getting the version you expect.

Set your path to include the J2SDK bin directory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic