How to set Java ?

Good day!
I going to launch Android Studio and install IntelliJ IDEA to my OpenSuse 12.1.
When I begun to do it I had seen:
"tools.jar’ seems to be not in IDEA classpath. Please ensure JAVA_HOME points to JDK rather than JRE. "
I changed JAVA_HOME strings in files: /etc/profile.d/ and /etc/profile.d/alljava.csh to another path and next message had appeared:
“OpenJDK 6 is not supported. Please use Oracle Java or newer OpenJDK.”
So, I install JDK 7 from oracle website, but nothing has change, and I changed “alljava” files back, but message still: “OpenJDK 6 is not supported. Please use Oracle Java or newer OpenJDK.”

What I need to do to make it work?
If somebody can tell how does programs use JDK, and what files is using for set global variables for environment - it will be really great.
Thnx in advantage.

openSUSE 12.1 is EOL by the way, you should look at upgrading to 13.1.

Run (as root):
update-alternatives --config java

Does it present you with multiple Java to choose from?

It writes that :
“There is only one alternative in link group java: /usr/lib64/jvm/jre-1.6.0-openjdk/bin/java
Nothing to configure.
update-alternatives: warning: forcing reinstallation of alternative /usr/lib64/jvm/jre-1.6.0-openjdk/bin/java because link group java is broken.”

Uninstall everything related to OpenJDK and install the RPM version of Java from (first uninstall it, then install the Oracle’s version or it won’t upgrade the files properly)

for example;
zypper rm "openjdk"

**zypper in jre-7u51-linux-x64.rpm
Tested it in a Virtual Machine and it worked fine;

aquila:/home/miuku # java -version
java version “1.7.0_51”
Java™ SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot™ 64-Bit Server VM (build 24.51-b03, mixed mode)

If a Java install didn’t install into update-alternatives you can

  • As Miuku suggests, uninstall all Java and then install your preferred leaving only the one available for use
  • Go through the update-alternatives MAN pages and add your new Java (The relatively simple command isn’t at the top of my head). This gives you the ability two switch between the two Java

Don’t forget to remove your modifications to /etc/profile.d/ and /etc/profile.d/alljava.csh

And, in the future if you want to over-ride default settings, the general recommendation (see comments in /etc/profile) is to create a file /etc/profile.local with your changes.

The general idea is to keep your customizations completely separate from defaults so you can easily return to defaults and if you install an update or upgrade those changes won’t over-write your customizations.

You <can> set your JAVA environmental variables in /etc/profile.local, I’ve done so in special circumstances.