Linux JAVA in path but permissions denied
Asked Answered
T

3

9

Im trying to get JAVA enabled on Intel Edison which uses Yocto (Linux), the problem is that after extracting the zip, im able to check the version, and when putting it into the path, im not able to access java at all due permissions.

Specifically im trying to follow this tutorial but i get "stuck" at the

. .profile

since next step

java -version

throws same issue as pasted below, permissions denied or as earlier, java was not found.

Heres a quick overview of output:

root@dedsec1:~/java/jdk1.7.0_67/bin# ./java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) Client VM (build 24.65-b04, mixed mode)
root@dedsec1:~/java/jdk1.7.0_67/bin# cd
root@dedsec1:~# echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/root/bin:/home/root/java/jdk1.7.0_67/bin:/home/root/java/jdk1.7.0_67/bin
root@dedsec1:~# ./java -version
-sh: ./java: Permission denied
root@dedsec1:~#

What the hell am i missing ? I have set chmod -x on java but it doesnt seem to affect it.

Tightwad answered 1/11, 2014 at 4:4 Comment(2)
offtopic. Do not do normal work under root account.Waiwaif
Try this root@dedsec1:~# java -version not root@dedsec1:~# ./java -versionSelfsatisfied
S
14
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0
Selfsatisfied answered 1/11, 2014 at 5:5 Comment(4)
Unfortunately sudo nor such are available, no idea what yocto has for options :/Tightwad
Tho I correct myself, running chmod a+x /root/bin/java did the trick and am able to call java now, what exactly is a ? I know x is executable.Tightwad
@DanelK a+x mean's add executable permissions to all usersSelfsatisfied
Aaaand, the first line was the answer I needed after 3 days of searching! Closes multiple open tabs and moves on happilyHydrofoil
S
2

root's home folder is not under "/home". Change this

/home/root/java/jdk1.7.0_67/bin:/home/root/java/jdk1.7.0_67/bin

to

/root/java/jdk1.7.0_67/bin

Also,

/home/root/bin

should probably be

/root/bin

For similar reasons. When writing a script you can use $HOME which will expand to wherever the user's home directory happens to be. So,

PATH="$HOME/bin:$HOME/java/jdk1.7.0_67/bin"

Edit

I would not recommend that you link to java in $HOME/bin. Let's set a JAVA_HOME and move that to the front of the PATH like

export JAVA_HOME=$HOME/java/jdk1.7.0_67
export PATH="$JAVA_HOME/bin:$HOME/bin:$PATH"
Shauna answered 1/11, 2014 at 4:13 Comment(0)
M
0

You need to be logged in as Root

. .profile

If that doesn't work you can source your file.

source .profile 

note that source is a synonym of '.' (period).

Mesh answered 1/11, 2014 at 4:32 Comment(5)
There is a space between the dots. And it is synonym for source.Shauna
When doing ssh root@ip im asked root pass which i hopefullay am logged in as :S but the output for source .profile gave me this: pastebin.com/iqcCn1bmTightwad
just enter java -version without the ./Mesh
once your executable can be located on your Path, you no longer need ./Mesh
Yeah Ive figured that but it doesn't seem to find java at allTightwad

© 2022 - 2024 — McMap. All rights reserved.