0

I am trying to execute a .run file that will install some applications. I'm installing the application in /opt/... When I run it without sudo, the installer runs correctly but cannot write to /opt/. When I run it with sudo, the installer complains that it cannot find a valid Java installation on the machine.

Java was installed using the oracle rpm

$rpm -ivh --prefix=javapath jdk1.7.0_75.x86_64.rpm   

$ which java
/usr/bin/java
$ echo $JAVA_HOME
/usr/lib/java-1.7.0/jdk1.7.0_75
$ sudo echo $JAVA_HOME
/usr/lib/java-1.7.0/jdk1.7.0_75
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/java-1.7.0/jdk1.7.0_75/bin
$ sudo echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/java-1.7.0/jdk1.7.0_75/bin
$ java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)
$ javac -version
javac 1.7.0_75

After this, a

$ ./installer.run

will work fine, but a

$ sudo ./installer.run

will return

Error: There has been an error.
The installer could not find a valid JAVA(tm) on this machine.

It's an application error not a system error.

  • Try sudo -e . – Minix Jul 14 '15 at 16:32
  • I tried sudo -e and it did not work (opened a text file to edit). However after some research I discovered -E would have worked. – Nilly Jul 15 '15 at 18:36
  • That's what I meant. My bad. Hope it didn't cause any harm. – Minix Jul 15 '15 at 21:44
0

Run sudo visudo or alternatively open /etc/sudoers

Check for the line secure_paths="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",

If your Java is located somewhere else add that path to this list.

  • Brilliant. Thanks. I have performed this installation in the path but never had to do this step (although this time I defined system environment variables in /etc/profile rather than just through export JAVA_HOME and export PATH. Do you know what might have caused this? – Nilly Jul 14 '15 at 16:54
  • Looks like you just broke the security. You could add a new bin folder somewhere, add it to the secure_paths, and then add a link to the java vm in it. This way you are only making the java vm an exception. – ctrl-alt-delor Jul 14 '15 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.