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
Answer from Srinivasu on Stack Overflowsudo 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"
To create a File into the same folder in your project, your path has to be relative.
The path that you are giving is absolute, because it is starting from /. For your path to be relative, remove / from the path and try this :
File file = new File("textfile.txt");
What you can do is to create a variable string, store the file name, and pass that string into the File file=new File(string);
Like the message says, you probably don't have permissions to read that file. To troubleshoot, you can add:
System.out.println(sourceFile.getAbsolutePath());
to find the exact location of the file that you're trying to read and then checking the file system permissions for it:
ls -la <path to your file>
Verify that you have the r permission, otherwise this is the error that you get.
One way to do this is to navigate to the file and change the permission to allow every user to read the file. The easiest is via terminal:
chmod +r /path/to/file
To see all the different uses follow the link and learn about chmod. https://codex.wordpress.org/Changing_File_Permissions