Find the answer to your Linux question:
Results 1 to 3 of 3
I installed Java SDK 1.4.2_07 a year or so ago on my Mandrake 10 Linux system in; /usr/java/j2sdk1.4.2_07/ In /etc/profile.d/ there is a file named java.sh the contents of this ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    une
    une is offline
    Just Joined!
    Join Date
    Sep 2006
    Location
    Australia
    Posts
    2

    My system can't find Java tools


    I installed Java SDK 1.4.2_07 a year or so ago on my Mandrake 10 Linux system in;
    /usr/java/j2sdk1.4.2_07/

    In
    /etc/profile.d/
    there is a file named java.sh
    the contents of this file are as follows;
    export PATH=$PATH:/usr/java/j2sdk1.4.2_07/bin/

    I believe this script is supposed to execute at login and allow Java tools to be used from any directory.
    It all worked fine. I could execute Java commands from any directory.

    Recently I connected a router to provide ADSL connectivity to the Internet.
    When I did this I noticed that my command prompt changed from;
    [username@localhost username]$
    to
    [username@myISP username]$

    As soon as the router was connected I found I could no longer get Java commands to work from anywhere.
    All I get is error messages such as;
    bash: java: command not found

    What has happened? Has an environment variable been changed?

    Here is the result of echo $PATH;
    [username@myISP username]$ echo $PATH
    /sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/share/pvm3
    /

    I tried executing java.sh after changing to the directory in which it is located as follows;
    [username@myISP profile.d]$ java.sh
    bash: java.sh: command not found


    I thought this comand would cause the script to execute, but it did not.
    How do I execute this script?

    I then manually executed the contents of java.sh as root by executing the line of code contained in it as a command from the command prompt as follows;
    [root@myISP username]# export PATH=$PATH:/usr/java/j2sdk1.4.2_07/bin/
    Then root could access Java commands OK, but only from the directory I was in when I executed the export command.
    username could not access Java tools yet.

    I then manually executed the contents of java.sh as username using the same method.
    [username@myISP username]$ export PATH=$PATH:/usr/java/j2sdk1.4.2_07/bin/
    Then username could access Java commands OK, but only from the directory I was in when I executed the export command.

    After logging out and back in, the effect of these export commands had gone.

    It seems that execution of the java.sh script at login is not working. Could this be asscociated with the change in host from localhost to myISP when I connected the router? This is after all the event that seemed to trigger this entire problem.

    How do I cause Java tools to automatically be accessable from all directories as they once were?

  2. #2
    Linux Guru fingal's Avatar
    Join Date
    Jul 2003
    Location
    Birmingham - UK
    Posts
    1,539
    Hi - Scary looking problem! I noticed you hadn't had a reply, so I'll do my best.

    Have you tried - in a terminal - entering the directory containing java.sh and as root doing:

    sh java.sh

    That should execute that script. When you installed your router the software you used just changed the settings for your command prompt. This is a pretty basic - and very rude - thing to do without your consent, but nothing major.
    I am always doing that which I can not do, in order that I may learn how to do it. - Pablo Picasso

  3. #3
    une
    une is offline
    Just Joined!
    Join Date
    Sep 2006
    Location
    Australia
    Posts
    2
    The problem was solved as follows;
    in /etc/bashrc I changed the last line from;
    export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/share/pvm3/

    TO

    export PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/share/pvm3/

    Why it worked I do not know. Any ideas?
    Thanks to Daniel from the SLUG (Sydney Linux Users Group).
    He saved my bacon.

Posting Permissions

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