2

So basically i have installed ubuntu bash from microsoft store in windows 10.I have installed java on ubuntu (the native os is windows 10).javac is working perfactly even it displays the version of java which i have installed(javac 9.0.4).The file name is HelloWorld.java.The java version and rest of the problem is displayed in the this image.

The code is simple hello world program

public class HelloWorld {

public static void main(String[] args) {
    // Prints "Hello, World" to the terminal window.
    System.out.println("Hello, World");
}

}

Even when i try to open the file with pico it displays the same error. [ Error reading HelloWorld.java: Permission denied ]

Solution: chmod u+r filename But one problem still remains is how to give this permission automatically to all the files which will be copied from windows to ubuntu directory?

  • Add the output of ls -l HelloWorld.java – user000001 Mar 17 '18 at 18:11
  • The output of ls -l HelloWorld.java is ---------- 1 aditya aditya 188 Mar 17 23:26 HelloWorld.java.It seems like it does not have any permission. @user000001 – Under_stand Mar 17 '18 at 18:16
  • it means you have no permissions. Try chmod u+r HelloWolrd.java, but I just noticed that it's on windows, no idea how you can fix permissions there, sorry.. – user000001 Mar 17 '18 at 18:19
  • 2
    I tried chmod u+r HelloWolrd.java and it worked thanks mate.But Every file that i created on windows copied in ubuntu directory(C:\Users\aditya\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home\aditya) should be modified with explicit permission to read how to avoid this problem?How to give it permission for reading automatically for the copied file @user000001? – Under_stand Mar 17 '18 at 18:27
0

To change permissions of all the .java files in the Ubuntu directory:

  1. Change directories with cd to the Ubuntu directory.

  2. Run this command:

    chmod u+rw *.java
    

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.