Author Topic: [Solved] - Java development kit - installation  (Read 1800 times)

Offline TruckerJohn

  • Jr. Member
  • **
  • Posts: 43
[Solved] - Java development kit - installation
« on: January 13, 2011, 07:02:44 AM »
Hi

I have downloaded and installed JDK-6u23-linux-i586.bin and appear to have installed in my home folder, which also contains some Java programs.  When, in a terminal, I run javac HelloWorld.java  I get the response javac - command not found
How do I resolve this?

Thanks
« Last Edit: January 16, 2011, 04:43:40 AM by TruckerJohn »

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6198
Re: Java development kit - installation
« Reply #1 on: January 13, 2011, 11:12:45 AM »

A program path must be in the "$PATH" environmental variable before you can call it without including its full path.

if you have installed it in your home folder, then you do have a folder called "jdk1.6.0_23" in your home folder, right? if yes then run these two commands first and then continue with your java programs, if no, then what is the full path to the java folder you installed java in?

export PATH=~/jdk1.6.0_23/bin:$PATH
export JAVA_HOME=jdk1.6.0_23

your java programs should work as expected now.

.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline TruckerJohn

  • Jr. Member
  • **
  • Posts: 43
Re: Java development kit - installation
« Reply #2 on: January 14, 2011, 06:12:36 AM »
Hi

Thanks for the reply but it didn't work

The jdk is installed in home/john/JavaPrograms

I have tried a couple of variations but I cannot get the correct PATH

John

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6198
Re: Java development kit - installation
« Reply #3 on: January 14, 2011, 11:39:56 AM »

Then there is a folder in that path where "javac" executable is located, thats the folder than need to be in the "PATH" variable.

what does this command give you? this will tell you where the executable is located without going through all folders manually.

find /home/john/JavaPrograms -iname "javac"
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12497
Re: Java development kit - installation
« Reply #4 on: January 15, 2011, 04:46:01 AM »
Why did you not install task-java and let it put java in your path instead of manually installing it in home? I suspect you would need to add the path to the binary in home to your .bash_profile



# User specific environment and startup programs

PATH=$PATH:$HOME/bin

Thanks to everyone who donates. You keep the servers running.

Offline TruckerJohn

  • Jr. Member
  • **
  • Posts: 43
Re: Java development kit - installation
« Reply #5 on: January 16, 2011, 03:46:26 AM »
Hi
Muungwana - the find command gives home/john/JavaPrograms/Jdk1.6.0_23/bin/javac

So I tried export Path=home/john/JavaPrograms/jdk1.6.0_23/bin
export JAVA_HOME=jdk1.6.0_23

but I still get command not found.

Texstar - tried using Synaptic to get task-java - failed to find packages on server.  This was the same result I got trying to install jdk using synaptic hence trying the manual route.

Offline Texstar

  • Administrator
  • Super Villain
  • *****
  • Posts: 12497
Re: Java development kit - installation
« Reply #6 on: January 16, 2011, 04:01:02 AM »
Did you like press reload to get a current file listing or not?


Thanks to everyone who donates. You keep the servers running.

Offline TruckerJohn

  • Jr. Member
  • **
  • Posts: 43
Re: Java development kit - installation
« Reply #7 on: January 16, 2011, 04:43:09 AM »
Sorted - reloaded Synaptic.
installed task -java and then jdk and it now works.

Thanks for the help.

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6198
Re: Java development kit - installation
« Reply #8 on: January 16, 2011, 10:52:49 AM »
Hi
Muungwana - the find command gives home/john/JavaPrograms/Jdk1.6.0_23/bin/javac

So I tried export Path=home/john/JavaPrograms/jdk1.6.0_23/bin
export JAVA_HOME=jdk1.6.0_23

but I still get command not found.

Texstar - tried using Synaptic to get task-java - failed to find packages on server.  This was the same result I got trying to install jdk using synaptic hence trying the manual route.
i am glad you got this sorted out, it is very important to follow instructions as they are given to you and best to copy and paste commands to make sure you dont mistype them.

"Path" is not the same as "PATH", me and texster used "PATH" because that is what you were supposed to use, you use "Path" and that is why it did not work.

You also for some reason consistently did not add the "/" infront of "home" in your path. These are those kind of little things that will drive you insane if you dont follow exactly because things will appear to simply not work for no good reason.

You already got this sorted out so do this for your own exercise knowledge of how linux works.

If you still have java in the same folder, then type these commands first to use your version of java.

export PATH=/home/john/JavaPrograms/jdk1.6.0_23/bin:$PATH
export LD_LIBRARY_PATH=/home/john/JavaPrograms/jdk1.6.0_23/lib:$LD_LIBRARY_PATH
export JAVA_HOME=/home/john/JavaPrograms/jdk1.6.0_23/

You have "java" installed at "/home/john/JavaPrograms/jdk1.6.0_23/" and those first two commands will the rest of your system where it is.
Now, a command "which javac" should give you "/home/john/JavaPrograms/jdk1.6.0_23/bin/javac".

The "which" command will tell you the full path to where the command is located on your system

You should remember that those first "export" commands are necessary to tell your system where you have install a program if you install it at a non standard location. You may not know what exactly they do but know that they must be there.

happy java coding  :D
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6198
Re: [Solved] - Java development kit - installation
« Reply #9 on: January 16, 2011, 10:58:13 AM »

oh, i forgot, we do not recommened installing packages out of our repositories. When you didnt find java on your system, the first thing you should have done was going to the repository and look for it there, the second thing you should have done is come to the forum and ask for advise of where to get and use it in a way that will not break your system.

Installing packages out of our repository will sooner or later break your system and supporting your install will become very difficult because it will be in a state the rest of us can not reproduce.
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Aradalf

  • Sr. Member
  • ****
  • Posts: 474
Re: Java development kit - installation
« Reply #10 on: January 16, 2011, 11:05:41 AM »
Sorted - reloaded Synaptic.
installed task -java and then jdk and it now works.

Thanks for the help.

In addition to what muungwana already said about not installing programs from outside the repos, if you never pressed reload, that means you also did not update your system according to the instructions given here at the forums. Before installing any packages, always go to Synaptic and press Reload > Mark all Upgrades > Apply > Apply. PCLOS is a rolling release, so all packages must be updated. Do not selectively upgrade.