Koozali.org: home of the SME Server

Trouble installin Java, problem with PATH???

Offline svetlo56

  • **
  • 39
  • +0/-0
Trouble installin Java, problem with PATH???
« on: August 30, 2004, 04:48:12 AM »
I am trying to install Java so I can install Jalbum which requires Java.
Java was installed as per http://www.helmuth.net/mitel-sme/SunJDK/sunjdk-howto-new.htm, found by search for Java in Contribs.org.

It seems to work, with a little problem. I tried a small Java program called test.java
[root@linux html]# javac test.java
bash: javac: command not found
[root@linux html]#


when I try
[root@linux html]# /usr/java/j2sdk1.4.1/bin/javac test.java
[root@linux html]#

then it works
[root@linux html]# /usr/java/j2sdk1.4.1/bin/java test
Hello world
[root@linux html]#


I then modified .bash_profile as per http://www.yolinux.com/TUTORIALS/LinuxTutorialJava.html

Set environment variables. (Add to $HOME/.bash_profile)

PATH=/usr/java/j2sdk1.4.1/bin:$PATH:$HOME/bin:./
export PATH
export JAVA_HOME=/usr/java/j2sdk1.4.1
export CLASSPATH=/usr/java/j2sdk1.4.1/lib/tools.jar:/usr/java/j2sdk1.4.1/jre/lib/rt.jar:./


Must include "./" in CLASSPATH. This is necessary in 1.4.0_03.

And it does not work, I still have to include /usr/java/j2sdk1.4.1/bin/javac test.java

And attempt to install Jalbum gives me this

[root@linux html]# sh ./jalbum.bin
Preparing to install...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
No Java virtual machine could be found from your PATH
environment variable.  You must install a VM prior to
running this program.
[root@linux html]#


So it seems that the PATH is not set properly.  Indeed,
[root@linux html]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/root/bin:/root/bin
[root@linux html]#

does not include the path to where Java is.

Can anybody help? What am I doing wrong? My knowledge of Linux is minuscule, so please, please include EVERY detail of commands. I am truly a beginner in Linux, so do please not flame me for including such little details above.
Thanks, svetlo56

tenanji

Trouble installin Java, problem with PATH???
« Reply #1 on: August 31, 2004, 04:02:40 AM »
I haven't tried this on an SME Server yet, but want to.  A quick question did you re-source your profile after you added the new environment variables?  

On my suse machine you can type ". .bash_profile" and it will reload it.  This can also be accomplished by logging out and then back in.

If the environment variables are set correctly you should be able to type "echo $JAVA_HOME" and it should display the value you entered into the .bash_profile.  If it does not your environment variables are not set.

I have also accomplished this by creating a shell script to start the java app.  This is particularly usefull if more than one version of java is on the machine.

Example run_it.sh
export JAVA_HOME=/usr/local/java131
java helloworld

end example

Everything looks correct, hope this helps.  I do work on an AIX system at work that I haven't been able to get the CLASSSPATH and JAVA_HOME to work either. Maybe we can work together to figure it out.  I will start installing SME 6.0 on a test machine I have here at home.

Let me know if you figure it oul.

Jay

tenanji

It's Alive - Getting java to work on SME Server 6.0.1-01
« Reply #2 on: August 31, 2004, 05:30:50 AM »
I just finished the install and proceeded with installing JAVA.  All is well, of course I haven't rebooted yet.  But I was able to install the Java SDK from sun.  I chose the compress rpm.  I like rpm's they are nice and neat.  No worries with ./configure, make, make test, make tea, make install, make clean.  Just rpm -Uvh package_name.rpm.

Ok so I downloaded the rpm directly from sun for version 1.4.2_05 (j2sdk1.4.2_05.rpm.bin)

http://javashoplm.sun.com/ECom/docs/Welcome.jsp?StoreId=22&PartDetailId=j2sdk-1.4.2_05-oth-JPR&SiteId=JSC&TransactionId=noreg

I used SSH ftp to put it on my SME Server.

I set the permissions executable (chmod 777 j2sdk1.4.2_05.rpm.bin)

I ran j2sdk1.4.2_05.rpm.bin, which after several screens of licensing unzipped the rpm.

I installed the rpm (rpm -Uvh j2sdk1.4.2.rpm)

I ran updatedb to allow me to use the locate command.  I use the locate command alot, it makes it very easy to find stuff.  Doing a locate java showed that it was installed in the /usr/java/j2sdk1.4.2_05 directory.

I opened .bash_profile and added the JAVA_HOME pointed at the /usr/java/j2sdk1.4.2_05 directory.  I added ./ and /usr/java/j2sdk1.4.2_05/bin to the path. Then resourced the environment by issuing a . .bash_profile.

Here is what my .bash_profile looks like now:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:./:"/usr/java/j2sdk1.4.2_05/bin"
BASH_ENV=$HOME/.bashrc
USERNAME="root"
JAVA_HOME="/usr/java/j2sdk1.4.2_05"

export USERNAME BASH_ENV PATH JAVA_HOME


I tested with a good ol echo $JAVA_HOME, had to do it twice because I misspelled it the first time.  I know how do you misspell Java_home, well I did. :-)

echo $JAVA_HOME produced /usr/java/j2sdk1.4.2_05

All is looking good so far. So on to the next step. A test application.  I whipped up the all too famous HelloWorld.java example

<pre>
public class HelloWorld {

// Display "Hello World!"
public static void main(String args[]) {
System.out.println("Hello World!");
}
}
</pre>
put that in HelloWorld.java, saved it and then ran javac HelloWorld.java and out came HelloWorld.class.

Next test run it, I issued the java HelloWorld command out popped Hello World!.

The rest of the How to install a JDK on SME about setting up the templates and actions I do not understand but will be reading over more closely to see if it will affect what I did.  The good news is that it all seems to be working.

I hope this helps you get it going on your machine.  Please let me know if this doesn't work and we can still colaborate on it.

tenanji

Trouble installin Java, problem with PATH???
« Reply #3 on: September 30, 2004, 05:22:51 AM »
Did this help?

Offline svetlo56

  • **
  • 39
  • +0/-0
Trouble installin Java, problem with PATH???
« Reply #4 on: October 03, 2004, 06:31:59 AM »
Yes it did, now all works like charm. Thanks a bunch!!

Inq

Trouble installin Java, problem with PATH???
« Reply #5 on: January 06, 2005, 06:17:25 PM »
Hi I've had the same trouble so I edited my .bash_profile in

/root/.bash_profile
/home/e-smith/.bash_profile
/etc/skel/.bash_profile

but I still cant get java to work from the command line

if I echo &JAVA_HOME i just get a blank CR then the prompt. their one other .bash_profiles

/home/e-smith/files/ezmlm/.bash_profile

but that cant be the one' used.

my bash is

Code: [Select]
PATH=$PATH:$HOME/bin:./:"/usr/java/jdk/bin"
BASH_ENV=$HOME/.bashrc
USERNAME="root"
JAVA_HOME="/usr/java/jdk"

export USERNAME BASH_ENV PATH JAVA_HOME
unset USERNAME


if you think the path to the jdk is wrong the symlnk works, ive tried with actual path and symlnk. neither work.. MAD any ideas?

tenanji

Trouble installin Java, problem with PATH???
« Reply #6 on: January 10, 2005, 04:00:59 AM »
If you echo JAVA_HOME and it is empty it not not set.

Two things to try.

1. Reload you profile . .bash_profile
2. Log out and then back in

Both of these should cause the contents of the .bash_profile to be reloaded.

Echo the $JAVA_HOME variable again.  It should display the path to the java install.

Hope this helps,
Jay