I tried to compile a Hello world example in java and got a gcc error. As far as I understand it, gcc is trying to compile my java class (and for some reason failing to find the main method, but that's beside the point). I have openSUSE 12.1 64 bit and JDK 1.7 (installed from Oracle's rpm). I have /usr/java/jdk1.7.0_04/bin/:/usr/java/jdk1.7.0_04/ in my $PATH. When I try to compile a java file, I get: rumtscho@bradbury:/tmp> javac Hello.java/usr/lib64/gcc/x86_64-suse-linux/4.6/../../../../lib64/crt1.o: In function `_start':/home/abuild/rpmbuild/BUILD/glibc-2.14.1/csu/../sysdeps/x86_64/elf/start.S:109: undefined reference to `main'Why is this happening and how can I correct the problem? My complete $PATH is: rumtscho@bradbury:/tmp> echo $PATH/home/rumtscho/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:.:/home/rumtscho/bin:/home/rumtscho/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/home/rumtscho/android-sdk-linux/tools:/home/rumtscho/android-sdk-linux/platform-tools:/usr/java/jdk1.7.0_04/bin/:/usr/java/jdk1.7.0_04/:/home/rumtscho/bin:/home/rumtscho/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/home/rumtscho/android-sdk-linux/tools:/home/rumtscho/android-sdk-linux/platform-tools:/usr/java/jdk1.7.0_04/bin/:/usr/java/jdk1.7.0_04/
What is wrong with my JDK installation?
opensuse;path;java
Commands are looked up in $PATH in the order in which the directories are listed. In your case, it is likely from your description that there is no /home/rumtscho/bin/javac, no /usr/local/bin/javac, but a /usr/bin/javac that is the GCC Java compiler (or a symbolic link to it).SuSE has an alternatives mechanism to handle programs that have multiple implementations. According to the SuSE documentation on installing Java, SuSE's Java packages use this mechanism. If the Oracle package respects this interface, then runupdate-alternatives --config javacto select your favorite Java compiler (you should do the same with java to select a matching runtime environment).If the Oracle binary is not mentioned in the list, you can manually switch to it:ln -snf /usr/java/jdk1.7.0_04/bin/{java,javac} /etc/alternatives/Alternatively (but this is not recommended if the alternatives method works), you can create a symbolic link to your prefered javac in your ~/bin directory (per-user setting) or in /usr/local/bin (system-wide setting).ln -s ../../java/jdk1.7.0_04/bin/javac /usr/local/binAnother way would be to reorder your PATH to have the Oracle JDK directory first. In your ~/.profile, make sure to add /usr/java/jdk1.7.0_04/bin at the beginning of your PATH. You can take the opportunity to remove it if it was already in the $PATH, to avoid duplicate entries (which are harmless except for a very slight slowdown when looking for a command at the end of $PATH or looking up a non-existent command name).prepend_to_path () {  PATH=:$PATH:  case $PATH in    *:$1:*) PATH=${PATH%%:$1:*}:${PATH#*:$1:};;  esac  PATH=$1${PATH%:}}prepend_to_path /usr/java/jdk1.7.0_04/bin