Results 1 to 17 of 17
  1. #1
    terahawks is offline Member
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default SOS for CLass Path in Linux

    Hi every body,

    Am facing a problem with setting of the class path for java in linux. Firstly i will explain you all my proc for setting up the classpath.

    I opened up the terminal of linux and typed vi /etc/profile which took me to the vi editor place. There is mentioned the class path like this >> JAVA_HOME=/usr/local/jre1.6.0_20/
    export $JAVA_HOME

    PATH=$PATH:$JAVA_HOME/bin
    export $PATH





    CLASSPATH=/usr/local/jre1.6.0_20:/usr/local/jre1.6.0_20/lib/rt.jar
    export $CLASSPATH


    after quitting the vi editor when i typed echo $CLASSPATH nd pressed the enter key nothing was visible, and also when i typed javac it gave a message command not found. CAn any one help me out with this?

    Thank you.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,000
    Blog Entries
    7
    Rep Power
    20

    Default

    Editing your file doesn't make your shell execute the file; after editing type:

    Java Code:
    source /etc/profile
    ... and see what happens.

    kind regards,

    Jos

  3. #3
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    You need to source your profile. That is done automatically when you login, or open a shell prompt, but not when you simply edit your profile. Type
    Java Code:
    . /etc/profile
    or open a new shell.

    You really should not, however, be setting these things in /etc/profile. That just leads to a lot of mantenance work when upgrading. However, if you insist on doing so, then create a /usr/local/jre link that points to the "current" version (not necessarily always the newest) and set those paths using that link.

    Edit: Too slow on that first part, I see. ;-)

  4. #4
    terahawks is offline Member
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default MEssage

    Yes i typed as u all said and this is wht i got >>

    shishirt:~/Desktop # . /etc/profile
    bash: export: `/usr/local/jre1.6.0_20/': not a valid identifier
    bash: export: `/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/local/jre1.6.0_20/bin:/usr/local/jre1.6.0_20/bin:/usr/local/jre1.6.0_20//bin': not a valid identifier
    bash: export: `/usr/local/jre1.6.0_20:/usr/local/jre1.6.0_20/lib/rt.jar': not a valid identifier
    shishirt:~/Desktop # source /etc/profile
    bash: export: `/usr/local/jre1.6.0_20/': not a valid identifier
    bash: export: `/sbin:/usr/sbin:/usr/local/sbin:/opt/gnome/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/local/jre1.6.0_20/bin:/usr/local/jre1.6.0_20/bin:/usr/local/jre1.6.0_20//bin:/usr/local/jre1.6.0_20//bin': not a valid identifier
    bash: export: `/usr/local/jre1.6.0_20:/usr/local/jre1.6.0_20/lib/rt.jar': not a valid identifier

  5. #5
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Because it is export PATH and export CLASSPATH not $PATH and $CLASSPATH.

  6. #6
    terahawks is offline Member
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default WOw!!!!

    YEs thanks that worked after the removal of $ sign. Great thanks once again but thing is that when i type echo $CLASSPATH it shoots this >/usr/local/jre1.6.0_20:/usr/local/jre1.6.0_20/lib/rt.jar fine but then again when i type javac in the terminal it says command not found.

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Because javac is not part of the jre, it is part of the jdk.

  8. #8
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    the linux manual says

    Now, if you want to be able to execute this version of Java interpretor or compiler from any directory on your GNU/Linux system you will have to create a few symbolic links:

    * ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
    * ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac

    You are done!

    the links must contain your directory where the java/javac files are and must be in the directory /usr/bin. forget the classpath for java and javac. with which distribution of linux are working?
    Last edited by j2me64; 05-03-2010 at 10:53 AM.

  9. #9
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by masijade View Post
    Because javac is not part of the jre, it is part of the jdk.

    in the actual version of Java SE Development Kit 6u20 for linux32 the javac is in ../java-6-sun/bin/javac and java is in ../java-6-sun/jre/bin/java.

  10. #10
    terahawks is offline Member
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default THanks

    Heyy

    the symbolic links which was shot >> ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
    ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac after typing those i got message file exists, and still when i shoot javac i still get command not found. Should i download the jdk kit??
    why does one need separate jre when the jdk comes with jre except for tht jre requires small space? :confused:

    Thanks.

  11. #11
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by terahawks View Post
    Heyy
    the symbolic links which was shot >> ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
    ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac after typing those i got message file exists, and still when i shoot javac i still get command not found.

    probably because the link is pointing to a non-existing file. before you delete anything can you post to which file the existing /usr/bin/java and /usr/bin/java are pointing? i'm asking because under linux ubuntu java is configured for java alternatives. which linux distribution are you using?

    Quote Originally Posted by terahawks View Post
    Should i download the jdk kit??

    if you want to develop and compile java-files then you need the jdk, but if you only need to run java-files the jre is ok.


    Quote Originally Posted by terahawks View Post
    why does one need separate jre when the jdk comes with jre except for tht jre requires small space? :confused:

    if you want to work with java you must get used that java can really be confusing ;)

  12. #12
    terahawks is offline Member
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default Yes

    Yes its damn confusing to the core.

    yes this is what am getting >>>>

    shishirt:/ # ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
    ln: creating symbolic link `/usr/bin/java' to `/usr/java/jdk1.6.0/bin/java': File exists
    shishirt:/ # ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac
    ln: creating symbolic link `/usr/bin/javac' to `/usr/java/jdk1.6.0/bin/javac': File exists

    So if i need to develop a java application or a java code all i need is JDK. And if to run a java application i need JRE.

    so as of now as a i need jdk not jre to develop codes??

    Thanks

  13. #13
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by terahawks View Post
    shishirt:/ # ln -s /usr/java/jdk1.6.0/bin/java /usr/bin/java
    ln: creating symbolic link `/usr/bin/java' to `/usr/java/jdk1.6.0/bin/java': File exists
    shishirt:/ # ln -s /usr/java/jdk1.6.0/bin/javac /usr/bin/javac
    ln: creating symbolic link `/usr/bin/javac' to `/usr/java/jdk1.6.0/bin/javac': File exists

    this is ok, because the links are already existing. before you try to override something can you please answers the following questions:

    1. to which directory/file the java and javac in /usr/bin are pointing?
    2. what do you get when you enter: sudo update-alternatives --config java
    3. which distribution of linux are you using (debian, ubuntu ...)?
    4. have you already downloaded the jdk for your machine?

    if we have an answer to this questions we can be able to fix your problem and to answer your last question, the jre is included in the jdk.

  14. #14
    terahawks is offline Member
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default REsponse

    Actually am using the suse 10.1 platform and yes i had JDK1.4 version installed originally.

    Thanks

  15. #15
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by terahawks View Post
    Actually am using the suse 10.1 platform and yes i had JDK1.4 version installed originally.

    Thanks
    is seems that the java and javac commands are in the /usr/bin but it's also looking that the links are unavailable. can you tell me where these two links are pointing to? we can fix your problem by bending this links to your jre1.6.0_20 directory.

  16. #16
    terahawks is offline Member
    Join Date
    Apr 2010
    Posts
    10
    Rep Power
    0

    Default Pointing

    I guess its pointing to usr/local/lib.


    Thanks

  17. #17
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by terahawks View Post
    I guess its pointing to usr/local/lib.
    Thanks

    ok, if java and javac are pointing to directories/files that dosn't exists delete these links in /usr/bin and create two new ones. be sure that the java is pointing to ../jre/bin/java (where .. is your jre1.6.0_20 directory) and javac is pointing to ../bin/javac (where .. is your jre1.6.0_20). watch out: from inside your jre1.6.0_20 directory, java is found in the subfolders jre/bin/java and javac is in the subfolder bin/javac (not jre/bin!). hope you understand. try and report.

Similar Threads

  1. setting class-path & Library Path in ubantu
    By programmer_007 in forum Eclipse
    Replies: 18
    Last Post: 02-22-2010, 12:31 PM
  2. how to set the class path
    By lashu in forum New To Java
    Replies: 1
    Last Post: 08-21-2009, 01:04 PM
  3. Cannot find Main class in Linux OS
    By msskiran in forum Eclipse
    Replies: 0
    Last Post: 04-10-2009, 02:04 AM
  4. Setting path under Linux to recognize jre
    By cccccc in forum New To Java
    Replies: 4
    Last Post: 03-31-2009, 06:51 AM
  5. trying to get class name & path
    By sandor in forum New To Java
    Replies: 4
    Last Post: 08-12-2008, 01:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •