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 Beginning Java and the fly likes Unable to Change Classpath 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 » Beginning Java
Bookmark "Unable to Change Classpath" Watch "Unable to Change Classpath" New topic
Author

Unable to Change Classpath

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 482
Hi Everyone,

I am trying to change classpath in a Sun Solaris from 1.4 to 1.6. But when I run the command:

I get the error:

Am i doing it correctly?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19908
    
  23

Try using this: No spaces around the =, I believe bash doesn't like them.

See also http://faq.javaranch.com/java/HowToSetTheClasspath


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 482
I ran the command and its taking it in properly, but when i run the command

I still get this:

And I am trying to execute a jar which throws the mojor.minor exception.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19908
    
  23

That's because you are mixing the CLASSPATH and PATH variables. You should change the PATH variable: Don't forget that trailing :$PATH or your path will no longer have /bin, /usr/bin etc in it.

Note that you should put the new JDK path before $PATH because the shell will look from start to end in the path. If you put it at the end the old java will be found.

Note 2: you can find out which java command is being executed by calling "which java".
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 482
Thanks for the help! But still not happening! I have attached the screenshot of what i am doing! Please take a look...



[Thumbnail for ScreenShot.JPG]

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41079
    
  29
Please don't attach a screenshot; it is difficult to read. Use ctrl-shift-C to copy from the terminal.

Why are you trying to set a CLASSPATH in the first place? Setting a system CLASSPATH is almost always a mistake.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41079
    
  29
Your PATH entry should end with /bin or /bin/
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 482
Thanks Cambell and Rob! Adding the /bin helped and my code is working now!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41079
    
  29
You're welcome. And delete the classpath, which you ought not to use.
 
I agree. Here's the link: http://kickstarter.com/rocket-mass-heater
 
subject: Unable to Change Classpath