How to Change Read-Only Status of Files in intellij

JavaIntellij Idea

Java Problem Overview


I have a Java project and I want to modify it in intellij but I can't do it because of this " read-only file " or "file is not writable" , so how I can modify and execute it?

this is the problem

Java Solutions


Solution 1 - Java

To toggle read-only attribute of a file, open file in the editor, or select it in the Project tool window. Do one of the following:

  • On the main menu, choose File | File Properties | Make File Read-Only, or Make File Writable.

enter image description here

  • Click the lock icon in the Status bar in the bottom right corner.

enter image description here

Solution 2 - Java

If IntelliJ IDEA is unable to change the file permissions using File | File Properties | Make File Writable, then perhaps another user is owning that file, e.g. root (use this command to verify: ls -hal /path/to/File.java)

If someone else owns it, for whatever reason, you can change the permissions yourself using the chown command in the terminal:

sudo chown yourusername /path/to/File.java,

where yourusername is the same user that you used to launch Intellij IDEA.

Solution 3 - Java

For Mac, this definitely works:

sudo chmod -R 777 /YourDirectory

Solution 4 - Java

I was just having this issue and I finally figured out where I was going wrong.

Over an hour of suggestions from Google didn't help. It turns out I was on files selected in the -out > production > MyPath folder instead of the -src folder in my project sidebar. Selecting the -scr > MyClass file allows me to do what I want to do.

Solution 5 - Java

If you're using Mac. Follow bellow steps:

  1. Open that file by Finder
  2. Right click and select Get Info
  3. In that File Info window, select Sharing and Permissions, change Privilege as you expected. Before changing, you would remember unlocking your change permission by click on a Locker Icon at bottom right.

enter image description here

Solution 6 - Java

On your top-left corner in the drop-down where you have Tests,Production,Problems switch/choose from Project or any other directory you've choosen to Packages, you'll have your packages editable, files in the Project folder are not editable although they end with .class extension.

Solution 7 - Java

This error appears when the other user has created those files.

  1. Right click on the file or folder to be deleted.
  2. Choose reveal in folder option.
  3. Delete the file and enter the password.
  4. Files will be deleted.

Solution 8 - Java

In case of working with SAP Hybris in IntelliJ, the OOTB module files are read-only (file is not writable) when you import the project with Hybris plugins.

  • While you are importing the project (re-import the project If already imported) , you will be prompted for Import Settings.

  • Uncheck the Import OOTB modules in read-only mode.

  • After importing , you should be able to edit the OOTB files.

Import Settings

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHarry Prn DzView Question on Stackoverflow
Solution 1 - JavaCarlos BernardesView Answer on Stackoverflow
Solution 2 - JavaHåvard GeithusView Answer on Stackoverflow
Solution 3 - JavaDato GogshelidzeView Answer on Stackoverflow
Solution 4 - JavatryingsohardView Answer on Stackoverflow
Solution 5 - JavaLong NguyenView Answer on Stackoverflow
Solution 6 - JavaCarlos MurrayView Answer on Stackoverflow
Solution 7 - JavaManish ChauhanView Answer on Stackoverflow
Solution 8 - JavaHarisudhaView Answer on Stackoverflow