0

Using Ubuntu 14.04, was trying to set simply JAVA PATH (that is where the saga began) now my system seems totally corrupted.

  1. I initially edited the PATH in etc/environment (that is where my PATH seems to be) and also added a line export JAVA_HOME.

    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/jdk1.8.0_111/bin"
    export JAVA_HOME=/opt/jdk1.8.0_111
    

This seemed to work till it did not. It did not work seemingly because of some old versions of JVM that were conflicting/confusing.

  1. Based on forum wisdom I edited .bashrc

    export JAVA_HOME= /opt/jdk1.8.0_111
    export  PATH= $PATH:$JAVA_HOME/bin 
    

    Probably there was some syntax error (or something).

Now I am getting all kinds of errors when I open a terminal:

bash: export: `=': not a valid identifier
bash: export: `/opt/jdk1.8.0_111': not a valid identifier
bash: export: `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/jdk1.8.0_111/bin:/opt/jdk1.8.0_111/bin': not a valid identifier

Note: Duplicate jdk in path - this likely is because PATH both in .bashrc and environment.

Now I am unable to find/edit either etc/environment or .bashrc

@ubuntu:~$ sudo gedit /etc/environment
bash: sudo: No such file or directory
@ubuntu:~$ sudo gedit ~/.bashrc
bash: sudo: No such file or directory

Fixed this above issue Thanks @muru

My core problem seemingly is caused by multiple java versions but I have only JAVA version

$ sudo update-alternatives --config java
update-alternatives: error: no alternatives for java

My program is not finding JAVA_HOME

$ sudo service dse start
Java executable not found (hint: set JAVA_HOME)

$ echo JAVA_HOME
JAVA_HOME
~$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)

Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

What do I do now?

0

2 Answers 2

2
export JAVA_HOME= /opt/jdk1.8.0_111
export  PATH= $PATH:$JAVA_HOME/bin 

These lines should not have spaces after =. Use /usr/bin/gedit ~/.bashrc and correct these lines:

export JAVA_HOME=/opt/jdk1.8.0_111
export PATH="$PATH:$JAVA_HOME/bin"
2
  • muru Thnaks. I was able to edit the .bashrc and fix the typos. Now No errors in booting. Also fixed the etc/environment removed the duplicate path there. But was getting errors on terminal
    – Sam-T
    Nov 21, 2016 at 16:53
  • My core problem of program not finding JAVA (seemingly caused duplicate java version remains) - I have only 1 java version and PATH and JAVA_HOME correctly set I can echo and -version
    – Sam-T
    Nov 21, 2016 at 17:03
1

I suspect that ~/.bashrc is not a good place to add Java folders to PATH, since it won't be effective in the graphical environment. I'd try to move those (corrected) lines from ~/.bashrc to ~/.profile and relogin.

1
  • Comments are not for extended discussion; the entire conversation that was taking place here has been moved to chat.
    – Thomas Ward
    Nov 23, 2016 at 1:16

Not the answer you're looking for? Browse other questions tagged .