I am looking to install kafka Manager tool,
I already have installed:
Kafka version 3.1.0
openjdk version "1.8.0_322"
The Java_HOME is:
~ $ echo $JAVA_HOME
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-11.el8.x86_64/jre
When I see official Yahoo Kafka Manager , it require Java 11+
https://github.com/yahoo/CMAK
But I have Java 8
I found an old git repository supporting Java 8:
https://github.com/BonnierNews/kafka-manager
in the tuto, Again, if java is not in your path, or you need to run against a different version of java, using the following :
$ PATH=/usr/lib/jvm/zulu-11-amd64/bin:$PATH \
JAVA_HOME=/usr/lib/jvm/zulu-11-amd64 \
/path/to/sbt -java-home /usr/lib/jvm/zulu-11-amd64 clean dist
But is it that this cmd with change the java path and will affect the infrastructure installe ????
How is it possible to install kafka Manager ?
is it ok if I install both java version?
You should definitely update Java.
Having both on your system is fine, but Java 8 will soon be end of life, and will not get security patches, potentially leaving your system to be vulnerable to exploits.
I would not recommend running old forks of CMAK only to workaround your need to use an older Java version
this cmd with change the java path and will affect the infrastructure installe ????
No. Those variables are only used for that sbt dist command
Alternative solution would be to run CMAK in Docker
So I've seen a bunch of tutorials on switching from Java 8 to Java 11, but I actually need to do the opposite. And I am doing it on a server, so I can use only bash.
I am pretty clueless of how to do it. Any help?
You can run this command and chose version java:
sudo update-alternatives --config java
This is what I do on my Debian system:
alias j8='export JAVA_HOME=/usr/lib/jvm/bellsoft-java8-full-amd64;export PATH=$JAVA_HOME/bin:$PATH'
This will ensure all executables are of the same version, and is a lot easier than update-alternatives, even if it did work (see my comments below another answer) or update-java-alternatives and is less error-prone
I use this tool SdkMan Install, SkMan manual
skd list java
print the versions of java available, and you can install it with comands like
sdk install java 8.0.292.hs-adpt
After you install a java version with sdkman set the java Home with
export JAVA_HOME=~/.sdkman/candidates/java/current
export PATH=$JAVA_HOME/bin:$PATH
you can install many java versions as you want and set your default version with
sdk default java 8.0.292.hs-adpt
If you use maven or gradle install them from sdkman, because in this way autodetects the version switching.
If you want to switch java versions only for specific projects check the env and .sdkmanrc part in the manual. It switches versions when you cd into a directory and go back to default when you cd out.
when running $sqldeveloper in order to open the app it returns the next message:
Default JDK not found
Type the full pathname of a JDK installation (or Ctrl-C to quit), the path will be stored in /home/adri/.sqldeveloper/19.2.1/product.conf
I'm in ubuntu and there goes some info about my jdk installation:
$sudo update-alternatives --config java
There is 1 choice for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 auto mode
* 1 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
$ls /usr/lib/jvm/
default-java java-1.8.0-openjdk-amd64 openjdk-11
java-11-openjdk-amd64 java-8-openjdk-amd64
$ls java-11-openjdk-amd64/bin/
jconsole
When typing java-11-openjdk-amd64 in the sqldeveloper opened terminal (as it was asked) it turns into that message:
Error: java-11-openjdk-amd64/bin/java not found or not a valid JDK
So the file 'java' is needed but I don't have it :C
Thanks for attention.
Bests,
I'm unable to add a comment as I am a new user here but I am wondering if there is something not quite right or missing in your environment.
I just created an Ubuntu 18.04 VM to match your o/s and used the Synaptic Package Manager to install openjdk-11-jdk (which installed a couple dependent packages as well). Here are the packages this process installed:
• openjdk-11-jdk
• openjdk-11-jdk-headless
• openjdk-11-jre
• openjdk-11-jre-headless
As thatjeffsmith mentioned the JDK is required (so that SQL Developer can use the JDWP debugging capabilities).
I then unzipped the following SQL Developer package which I had previously downloaded:
• sqldeveloper-19.2.1.247.2212-no-jre.zip
After changing to the correct directory (~/Applications/sqldeveloper/19.2/sqldeveloper in my case) I started SQL Developer as follows:
./sqldeveloper.sh
I then imported my connections from a previous export and was able to connect successfully. I only did a few tests in the Worksheet and browsing objects owned by my user but I didn't encounter any issues using OpenJDK 11.
I had previously encountered issues with OpenJDK 11 and OpenJFX 11 — you can read about that here:
A Tale: SQL Developer 19.2 on Ubuntu 18.04 with OpenJDK 11 and OpenJFX 11
The essence of that thread is that I had "pre-installed" the OpenJFX 11 libraries and that caused a conflict with the OpenJFX 12 libraries that SQL Developer installed automatically.
If you are still trying to pursue this I recommend ensuring you have a the JDK installed and verify as I have done in the following:
markwill#ubuntu18-vm01:~$ which javac
/usr/bin/javac
markwill#ubuntu18-vm01:~$ javac -version
javac 11.0.4
If someone is still struggling with openJDK. It won't work.
For some reason it just doesn't work with openjdk (despite it used to) but it does with JDK.
Just go here, download the *.rpm file and install it extracting with $sudo alien --scripts and $gdebi ./[Extracted_file].
Just provide sqldeveloper the /usr/java/jdk1.8.0_181 path.
Thanks for the comments, I was going mad...
I want to install OpenJDK Java on Mac OSX and have it work alongside other JDK's since it is a newer release. Currently, I downloaded the tar.gz and placed it in my path but that is hard to maintain.
The only other install I found that do more things automatically is the install via Homebrew cask. It looks like only the current version too:
brew cask info java
Shows:
java: 13,33:5b8a42f3905b406298b72d750b6919f6
https://openjdk.java.net/
So I can install it from there, but then what? Am I stuck only with the new version?
Note: These solutions work for various versions of Java including Java 8 through Java 17 (the LTS version) and Java 18. This includes alternative JDK's from OpenJDK, Oracle, IBM, Azul, Amazon Correto, Graal and more. Easily work with Java 7, Java 8, Java 9, Java 10, Java 11, Java 12, Java 13, Java 14, Java 15, Java 16, Java 17, Java 18, and the latest Java 19!
You have a few options for how to do the installation as well as manage JDK switching. Installation can be done by Homebrew, SDKMAN, asdf, or a manual install. Switching can be done by SDKMAN, asdf, or manually by setting JAVA_HOME. All of these are described below.
TL;DR - Preferred Methods of Installation
You can install Java using whatever method you prefer including SDKMAN, asdf, Homebrew, or a manual install of the tar.gz file. The advantage of a manual install is that the location of the JDK can be placed in a standardized location for Mac OSX.
However, there are easier options such as SDKMAN and asdf that also will install other important and common tools for the JVM. These two primary options are described here.
Installing and Switching versions with SDKMAN
SDKMAN is a bit different and handles both the install and the switching. SDKMAN also places the installed JDK's into its own directory tree, which is typically ~/.sdkman/candidates/java. SDKMAN allows setting a global default version, and a version specific to the current shell.
Install SDKMAN from https://sdkman.io/install
List the Java versions available to make sure you know the version ID
sdk list java
Install one of those versions, for example, Java 17 LTS:
sdk install java 17-open
Or java 19:
sdk install java 19-open
Make Java 17 the default version:
sdk default java 17-open
Or switch to 17 for the current terminal session:
sdk use java 17-open
When you list available versions for installation using the list command, you will see a wide variety of distributions of Java:
sdk list java
And install additional versions, such as JDK 11 from Amazon:
sdk install java 11.0.14.10.1-amzn
SDKMAN can work with previously installed existing versions. Just do a local install giving your own version label and the location of the JDK:
sdk install java my-local-13 /Library/Java/JavaVirtualMachines/jdk-13.jdk/Contents/Home
And use it freely:
sdk use java my-local-13
SDKMAN will automatically manage your PATH and JAVA_HOME for you as you change versions. And as a note, it installs Java versions to ~/.sdkman/candidates/java/.
More information is available in the SDKMAN Usage Guide along with other SDK's it can install and manage such as Gradle, Maven, Kotlin, Quarkus, Spring Boot, and many others.
Installing and Switching versions with "asdf"
asdf is a version manager that supports installing and managing most languages, frameworks, and developer/devops tools. It has language specific plugins including one for Java.
First, install asdf via https://asdf-vm.com/guide/getting-started.html (read there to setup your shell correctly), or more simply:
brew reinstall asdf
and read the doc for setting up your shell correctly, but if you are using asdf from Homebrew with ZSH you can execute this command to finish setup:
echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
Then install the Java plugin via https://github.com/halcyon/asdf-java
asdf plugin add java
and read the doc for setting up your shell correctly before continuing. Basically it says to add the following to your ~/.zshrc file (assuming you are not using another shell):
. ~/.asdf/plugins/java/set-java-home.zsh
Now list Java versions:
asdf list-all java
Install your favorite flavor and version:
asdf install java openjdk-17
or install the latest:
asdf install java latest
Other important commands are...
List your installed versions:
asdf list java
Set a global Java version:
asdf global java openjdk-17
Set a local Java version for a directory:
asdf local java openjdk-19
It's that easy! asdf will automatically manage your PATH and JAVA_HOME for you as you change versions. As a note, asdf installs Java versions to ~/.asdf/installs/java.
There are other languages and plugins for asdf here from the repository page: https://github.com/asdf-vm/asdf-plugins
Other Methods of Installation
Install with Homebrew
The version of Java available in Homebrew Cask previous to October 3, 2018 was indeed the Oracle JVM. Now, however, it has now been updated to OpenJDK. Be sure to update Homebrew and then you will see the lastest version available for install.
install Homebrew if you haven't already. Make sure it is updated:
brew update
Add the casks tap:
brew tap homebrew/cask-versions
These casks change their Java versions often, and there might be other taps out there with additional Java versions.
Look for installable versions:
brew search java
or for Eclipse Temurin versions:
brew search temurin
Check the details on the version that will be installed:
brew info java
or for the Temurin version:
brew info temurin
Install a specific version of the JDK such as java11, temurin8, temurin11, temurin17, or just java or temurin for the most current of that distribution. For example:
brew install java
brew install --cask temurin
And these will be installed into /Library/Java/JavaVirtualMachines/ which is the traditional location expected on Mac OSX. There might be additional steps to make the JDK active reported at the end of the install process.
Install manually from OpenJDK download page:
If you need any and every version of Java, this is a good place to look.
Download OpenJDK for Mac OSX from http://jdk.java.net/ (for example Java 17 and Java 19)
Unarchive the OpenJDK tar, and place the resulting folder (i.e. jdk-17.jdk) into your /Library/Java/JavaVirtualMachines/ folder since this is the standard and expected location of JDK installs. You can also install anywhere you want in reality.
Set JAVA_HOME environment variable to point at direction where you unarchived the JDK.
For further information see the answer specific to manual installation. Also see the section below "Switching versions manually" for more information on how to manage multiple manual installations.
Other installation options:
Some other flavours of OpenJDK are:
Azul Systems Java Zulu certified builds of OpenJDK can be installed by following the instructions on their site.
Zulu® is a certified build of OpenJDK that is fully compliant with the Java SE standard. Zulu is 100% open source and freely downloadable. Now Java developers, system administrators, and end-users can enjoy the full benefits of open source Java with deployment flexibility and control over upgrade timing.
Amazon Correto OpenJDK builds have an easy to use an installation package for Java 8, 11, 15, 16, 17, 18, and Java 19. It installs to the standard /Library/Java/JavaVirtualMachines/ directory on Mac OSX.
Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that will include performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.
Microsoft Java JDK - certified builds of OpenJDK from Microsoft.
Where is my JDK?!?!
To find locations of previously installed Java JDK's installed at the default system locations, use:
/usr/libexec/java_home -V
Matching Java Virtual Machines (4):
19 (x86_64) "Homebrew" - "OpenJDK 19" /usr/local/Cellar/openjdk/19/libexec/openjdk.jdk/Contents/Home
18.0.1.1 (x86_64) "Homebrew" - "OpenJDK 18.0.1.1" /usr/local/Cellar/openjdk/18.0.1.1/libexec/openjdk.jdk/Contents/Home
17 (x86_64) "Homebrew" - "OpenJDK 17" /usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home
11, x86_64: "Java SE 11" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home /usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home
You can also report just the location of a specific Java version using -v. For example for Java 17:
/usr/libexec/java_home -v 17
/usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home
Knowing the location of the installed JDK's is also useful when using tools like JEnv, or adding a local install manually to SDKMAN -- and you need to know where to find them.
If you need to find JDK's installed by other tools, check these locations:
SDKMAN installs to ~/.sdkman/candidates/java/
asdf install to ~/.asdf/installs/java
Version Switching
If you are using SDKMAN or asdf you are already covered and can stop reading! Otherwise, here are some options to switch existing VM installations.
Switching versions manually
The Java executable is a wrapper that will use whatever JDK is configured in JAVA_HOME, so you can change that to also change which JDK is in use.
For example, if you installed or untar'd JDK 16 to /Library/Java/JavaVirtualMachines/jdk-16.jdk if it is the highest version number it should already be the default, if not you could simply set:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
And now whatever Java executable is in the path will see this and use the correct JDK.
A simple way to change JDKs is to create a function in your ~/.bashrc or ~/.zshrc file:
jdk() {
version=$1
export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
java -version
}
And then change JDKs simply by:
jdk 1.8
jdk 9
jdk 11
jdk 13
Edits:
removed Jabba and JENV as both appear to have stagnated, issue count is climbing dramatically, and issues/PR's are not being addressed by the maintainers.
This is how I did it.
Step 1: Install Java 11
You can download Java 11 dmg for mac from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
Step 2: After installation of Java 11. Confirm installation of all versions. Type the following command in your terminal.
/usr/libexec/java_home -V
Step 3: Edit .bash_profile
sudo nano ~/.bash_profile
Step 4: Add 11.0.1 as default. (Add below line to bash_profile file).
export JAVA_HOME=$(/usr/libexec/java_home -v 11.0.1)
to switch to any version
export JAVA_HOME=$(/usr/libexec/java_home -v X.X.X)
Now Press CTRL+X to exit the bash. Press 'Y' to save changes.
Step 5: Reload bash_profile
source ~/.bash_profile
Step 6: Confirm current version of Java
java -version
With Homebrew and jenv:
Assumption: Mac machine and you already have installed homebrew.
Install Java from official Oracle website. You can install multiple versions of JDK. It will install on the following path:
/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/
/Library/Java/JavaVirtualMachines/jdk1.11.0_2.jdk/
/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/
Without jenv, system will use the java which installed last.
If you want to use/manage multiple version then you can use jenv:
Install and configure jenv:
$ brew install jenv
$ echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.zshrc
$ echo 'eval "$(jenv init -)"' >> ~/.zshrc
$ source ~/.zshrc
Add the installed java to jenv:
$ jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
$ jenv add /Library/Java/JavaVirtualMachines/14.0.2.jdk/Contents/Home
To see all the installed java:
$ jenv versions
Above command will give the list of installed java:
system
1.8
* 1.8.0.291 (set by /Users/lpatel/.jenv/version)
14
14.0
14.0.2
oracle64-1.8.0.291
oracle64-14.0.2
Configure the java version which you want to use:
$ jenv global 1.8.0.291
Manually switching system-default version without 3rd party tools:
As detailed in this older answer, on macOS /usr/bin/java is a wrapper tool that will use Java version pointed by JAVA_HOME or if that variable is not set will look for Java installations under /Library/Java/JavaVirtualMachines/ and will use the one with highest version. It determines versions by looking at Contents/Info.plist under each package.
Armed with this knowledge you can:
control which version the system will use by renaming Info.plist in versions you don't want to use as default (that file is not used by the actual Java runtime itself).
control which version to use for specific tasks by setting $JAVA_HOME
I've just verified this is still true with OpenJDK & Mojave.
On a brand new system, there is no Java version installed:
$ java -version
No Java runtime present, requesting install.
Cancel this, download OpenJDK 11 & 12ea on https://jdk.java.net ;
install OpenJDK11:
$ cd /Library/Java/JavaVirtualMachines/
$ sudo tar xzf ~/Downloads/openjdk-11.0.1_osx-x64_bin.tar.gz
System java is now 11:
$ java -version
openjdk version "11.0.1" 2018-10-16
[...]
Install OpenJDK12 (early access at the moment):
$ sudo tar xzf ~/Downloads/openjdk-12-ea+17_osx-x64_bin.tar.gz
System java is now 12:
$ java -version
openjdk version "12-ea" 2019-03-19
[...]
Now let's "hide" OpenJDK 12 from system java wrapper:
$ cd jdk-12.jdk/Contents/
$ sudo mv Info.plist Info.plist.disabled
System java is back to 11:
$ java -version
openjdk version "11.0.1" 2018-10-16
[...]
And you can still use version 12 punctually by manually setting JAVA_HOME:
$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
$ java -version
openjdk version "12-ea" 2019-03-19
[...]
If you have multiple versions installed on your machine, add the following in bash profile:
export JAVA_HOME_7=$(/usr/libexec/java_home -v1.7)
export JAVA_HOME_8=$(/usr/libexec/java_home -v1.8)
export JAVA_HOME_9=$(/usr/libexec/java_home -v9)
And add the following aliases:
alias java7='export JAVA_HOME=$JAVA_HOME_7'
alias java8='export JAVA_HOME=$JAVA_HOME_8'
alias java9='export JAVA_HOME=$JAVA_HOME_9'
And can switch to required version by using the alias:
In terminal:
~ >> java7
export JAVA_HOME=$JAVA_7_HOME
Another alternative is using SDKMAN! See https://wimdeblauwe.wordpress.com/2018/09/26/switching-between-jdk-8-and-11-using-sdkman/
First install SDKMAN: https://sdkman.io/install and then...
Install Oracle JDK 8 with: sdk install java 8.0.181-oracle
Install OpenJDK 11 with: sdk install java 11.0.0-open
To switch:
Switch to JDK 8 with sdk use java 8.0.181-oracle
Switch to JDK 11 with sdk use java 11.0.0-open
To set a default:
Default to JDK 8 with sdk default java 8.0.181-oracle
Default to JDK 11 with sdk default java 11.0.0-open
You can use asdf to install and switch between multiple java versions. It has plugins for other languages as well. You can install asdf with Homebrew
brew install asdf
When asdf is configured, install java plugin
asdf plugin-add java
Pick a version to install
asdf list-all java
For example to install and configure adoptopenjdk8
asdf install java adoptopenjdk-8.0.272+10
asdf global java adoptopenjdk-8.0.272+10
And finally if needed, configure JAVA_HOME for your shell. Just add to your shell init script such as ~/.zshrc in case of zsh:
. ~/.asdf/plugins/java/set-java-home.zsh
IMHO, There is no need to install all the additional applications/packages.
Check available versions using the command:
> /usr/libexec/java_home -V
Matching Java Virtual Machines (8):
11, x86_64: "Java SE 11-ea" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
10.0.2, x86_64: "Java SE 10.0.2" /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
9.0.1, x86_64: "Java SE 9.0.1" /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
1.8.0_181-zulu-8.31.0.1, x86_64: "Zulu 8" /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
1.8.0_151, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
1.7.0_80, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home
1.6.0_65-b14-468, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Now if you want to pick Azul JDK 8 in the above list, and NOT Oracle's Java SE 8, invoke the command as below:
> /usr/libexec/java_home -v 1.8.0_181
/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
To pick Oracle's Java SE 8 you would invoke the command:
> /usr/libexec/java_home -v 1.8.0_151
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
As you can see the version number provided shall be the unique set of strings: 1.8.0_181 vs 1.8.0_151
This answer extends on Jayson's excellent answer with some more opinionated guidance on the best approach for your use case:
SDKMAN is the best solution for most users. It's easy to use, doesn't have any weird configuration, and makes managing multiple versions for lots of other Java ecosystem projects easy as well.
Downloading Java versions via Homebrew and switching versions via jenv is a good option, but requires more work. For example, the Homebrew commands in this highly upvoted answer don't work anymore. jenv is slightly harder to setup, the plugins aren't well documented, and the README says the project is looking for a new maintainer. jenv is still a great project, solves the job, and the community should be thankful for the wonderful contribution. SDKMAN is just the better option cause it's so great.
Jabba is written is a multi-platform solution that provides the same interface on Mac, Windows, and PC (it's written in Go and that's what allows it to be multiplatform). If you care about a multiplatform solution, this is a huge selling point. If you only care about running multiple versions on your Mac, then you don't need a multiplatform solution. SDKMAN's support for tens of popular SDKs is what you're missing out on if you go with Jabba.
Managing versions manually is probably the worst option. If you decide to manually switch versions, you can use this Bash code instead of Jayson's verbose code (code snippet from the homebrew-openjdk README:
jdk() {
version=$1
export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
java -version
}
Jayson's answer provides the basic commands for SDKMAN and jenv. Here's more info on SDKMAN and more info on jenv if you'd like more background on these tools.
To stay with a specific major release, activate the AdoptOpenJDK tap with brew tap and then install the desired version with brew cask install:
$ brew tap AdoptOpenJDK/openjdk
$ brew cask install <version>
To install AdoptOpenJDK 14 with HotSpot, run:
$ brew tap AdoptOpenJDK/openjdk
$ brew cask install adoptopenjdk14
You can install the JDK version in any way you want.
Homebrew
SDK man
Manually
Then, I recommend using JENV to switch between different versions and use the JDK you need globally or locally.
You can find more details about how to install and use JENV here ->
https://blog.adamgamboa.dev/2021/06/17/using-jenv-to-switch-jkd-versions/
How to upgrade the java version from 1.4 to next version in linux ?
When i give a command java -version , getting output having java 1.4 version.
I want to upgrade from java 1.4 to java 1.6 version. How to achieve this ?
While you could download Java off the net, extract it and install it, you should stick to using your distribution's package manager in order to ensure proper version management and maintainability of your OS. Each Linux distribution has its own package manager (Debian uses apt/dpkg, Red Hat uses yum and so forth), so you should familiarize yourself with the relevant package manager and take it from there.
(Also, positively consider #Thilo's advice about skipping 1.6.)
Using which java should be able to tell you where java is installed on your local Linux server. It is likely to be a symbolic link to /usr/bin/java (I say usually because on AIX it is different).
Now, assuming you have a new version of JAVA installed in /usr/local/java_xxxx (you decide which one you want), simply update your symbolic link to java and javac.
ln -s -v /usr/local/java_xxxx/java /usr/bin/java
ln -s -v /usr/local/java_xxxx/javac /usr/bin/javac
And now java -version should give you the latest installed copy. For other 'detailed' instructions look here