Permission denied on checking java version in ubuntu - java

On asking java -version -
java -version
bash: /home/user/jdk-8u221-linux-x64/jdk1.8.0_221/bin/java: Permission denied
it says permission denied , but on using sudo it gives.
Due to which intelliJ is also not able to build project .
How to get access or how do I provide priveleg to the user
also showing problem in intellij -

You could try this command
sudo chmod a+x /usr/bin/java

Related

bash: /usr/local/android-sdk-linux/tools/android: Permission denied

i am trying to install phone gap on Ubuntu. I followed all the necessary steps and successfully installed the android sdk on Ubuntu. but when I type android in the terminal it shows permission denied. How do i change the permission.
The error is:
bash: /usr/local/android-sdk-linux/tools/android: Permission denied
Set the permissions using chmod exec'd using sudo
sudo chmod a+x /usr/local/android-sdk-linux/tools/android
Simply fix the rights
chmod +x /usr/local/android-sdk-linux/tools/android
and enjoy.
Hit CTRL + ALT + T , then write :
sudo chmod a+x /usr/local/android-sdk-linux/tools/android
and enter.
this will grant you all your necessary action in android

Linux JAVA in path but permissions denied

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.
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
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"
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).

Can not run java in spark worker

When I was running a spark program in the cluster, I got this error in log:
java.io.IOException: Cannot run program "java" (in directory "/cloud/packages/spark-0.9.0-incubating-bin-hadoop1/work/app-20140424114752-0000/0"): java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at org.apache.spark.deploy.worker.ExecutorRunner.fetchAndRunExecutor(ExecutorRunner.scala:129)
at org.apache.spark.deploy.worker.ExecutorRunner$$anon$1.run(ExecutorRunner.scala:59)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 2 more
I have set JAVA_HOME(/cloud/packages/jdk1.6.0_38) and SPARK_HOME(/cloud/packages/spark-0.9.0-incubating-bin-hadoop1).
What's the causes of this exception? How to fixed it?
I encountered the same issue on Ubuntu 12.04, and fixed it by adding JAVA_HOME in /etc/environment.
Check your java version.
java -version
If java is installed properly it displays Java version.
If not Install java(Ubundu)
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
update
Please check echo $JAVA_HOME.
Else set java home in .bashrc
export JAVA_HOME=/cloud/packages/jdk1.6.0_38
export PATH=$PATH:$JAVA_HOME/bin
In a shell, you are accustomed to being able to run java and letting the shell consult the PATH to go find where it is. Here you are invoking a command directly in the OS. It can't find java as it says. You can use a shell like bash to invoke the command for you, or give a full path to java.
Why though? why not run Java code inside the worker?

Adb permission denied when run from Java program

I'm trying to run chimpchat from Java code and I get this error:
Unexpected exception 'Cannot run program
"/home/asco/adt-bundle-linux-x86_64/sdk/platform-tools": error=13,
Permission denied' while attempting to get adb version from
'/home/asco/adt-bundle-linux-x86_64/sdk/platform-tools
I can run adb from the shell as a normal user. I've chmod 777'ed the adb program.
What can I do? I run Linux Mint 14 (64bit) (have ia32-libs installed) and use java7-openjdk-amd64.
When I tried to open the Android SDK from Eclipse I also received the error
"...Permission denied' while attempting to get adb version from '..."
initially, I tried
sudo apt-get install ia32-libs
but it did not fix the problem. i had them already.
What fixed the problem was
sudo chmod -R 777 /name-of-root-directory-containing-SDK
Recommendation! Place SDK, JDK and all other manually installed non-system resources in their own root directory.
[ example: /resource ]
Permissions set on this directory make no change to any critical files.
Warning!
Erroneous use of chmod -R on system directories can lead to "must reinstall OS from scratch"
it then complains about not finding the adb program
you need to install ia32-libs package:
sudo apt-get install ia32-libs
The error is specifying the directory that contains adb, rather than the adb executable itself. Check the permissions on the directory, and that your program is attempting to run the proper command (it may be trying to run the directory, which clearly won't work...).

JAVA_HOME environment variable not set Validator.nu HTML Parser

I am trying to install a local version of the Validator.nu server and it keeps failing on trying to build the HTML Parser.
It says it can't find the JAVA_HOME variable which I have set in my .bashrc file and shows correctly when I type "echo $JAVA_HOME" at the prompt
Ideas appreciated thanks
Error output
"hg" pull --update -R build https://bitbucket.org/validator/build/
Not trusting file build/.hg/hgrc from untrusted user dave, group dave
Not trusting file /home/dave/src/checker/build/.hg/hgrc from untrusted user dave, group dave
warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified (check hostfingerprints or web.cacerts config setting)
pulling from https://bitbucket.org/validator/build/
warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified (check hostfingerprints or web.cacerts config setting)
searching for changes
no changes found
Error: The JAVA_HOME environment variable is not set.
Set the JAVA_HOME environment variable to the pathname of the directory where your JDK is installed.
Instead of:
$ sudo python build/build.py all
try:
$ sudo -E python build/build.py all
The sudo command for security reasons resets the environment (so your JAVA_HOME for the python process is wiped out even when it's exported). The "sudo -E" will preserve the environment.
I assume (from tag) you use ubuntu.
list versions of installed javas in your system:
dave#ubuntu:~$ update-java-alternatives --list
java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
Note, that if you set JAVA_HOME in ~/.bashrc it will be set only in your terminal sessions.
Unless you export it, it will be set only for your current shell process (not subprocesses like mercurial).
add line to your .bashrc:
export JAVA_HOME="/usr/lib/jvm/java-6-openjdk"
open a new terminal and test it:
$JAVA_HOME/bin/java -version && echo java seen by bash
bash -c '$JAVA_HOME/bin/java -version && echo java seen by bash subprocesses'
If you want to set environment for all processes (not only started by hand from terminal), you can:
dave#ubuntu:~$ sudo $EDITOR /etc/environment
After tackling this for the last 4 days I have managed to get the validator.nu server running on my local Ubuntu VM and so I thought I would update this thread in case anyone else runs in to the same issues.
I am still not 100% sure where the original issue with the JAVA_HOME variable was coming from but I suspect (although I am not an expert at this) that it had something to do with the way I was using sudo to run the python build.
I was initially following the instructions on http://about.validator.nu/#src but using
$ sudo python build/build.py all
This was because part of the build needed the correct permissions to work.
This is my step-by-step process which starts from a clean install of Ubuntu 11.
installed ubuntu 11
opened the terminal
sudo /bin/bash <----------- I THINK THIS IS THE CRUCIAL LINE
apt-get install mercurial
apt-get install subversion
apt-get install openjdk-6-jre
apt-get install openjdk-6-jdk
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
follow rest of http://about.validator.nu/#src instructions
I'm going to need to do it again when I set this up for the internal network for our build scripts so i'll edit this if I've missed out on anything.
Hope this saves another person's headache and lost days!

Categories

Resources