Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9067789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:01:52+00:00 2026-06-16T17:01:52+00:00

After compiling the following code in Eclipse using a Mac: import java.io.*; public class

  • 0

After compiling the following code in Eclipse using a Mac:

    import java.io.*;

    public class Filer{
        public static void main(String[] args) throws IOException{

        File f1;

        f1 = new File("/System/file.txt");

        if(!f1.exists()){
            f1.createNewFile();

        }
      }
    }

I get an error:

    Exception in thread "main" java.io.IOException: Permission denied
        at java.io.UnixFileSystem.createFileExclusively(Native Method)
        at java.io.File.createNewFile(File.java:883)
        at Filer.main(Filer.java:11)

Can anyone tell me why that is? Is there any way to change the permissions? And if I were to compile this as a .jar file and send it to someone, would that person have the correct permissions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:01:53+00:00Added an answer on June 16, 2026 at 5:01 pm

    Can anyone tell me why that is?

    Your user doesn’t have permission to create a file in that directory.

    Is there any way to change the permissions?

    The same way you would change the permissions of any directory.

    In Java 7+

    Files.setPosixFilePermisions(f1.toPath(), 
        EnumSet.of(OWNER_READ, OWNER_WRITE, OWNER_EXECUTE, GROUP_READ, GROUP_EXECUTE));
    

    And if I were to compile this as a .jar file and send it to someone, would that person have the correct permissions?

    I suspect the correct permissions for a directory called /System is that you NOT have write access.

    Is there any reason not to use the home directory or the current working directory?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written following java code: public static void main(String[] args) { Vector vector
Consider following code: public sealed class Program { public static void Main() { System.Console.WriteLine(Hi);
After compiling my java code under Eclipse, I got the following error messages: SLF4J:
When run following code after compiling on gcc,I get segmentation fault. #include <stdio.h> #include
I tried compiling the following code using Dev c++ . It gives my crazy
I'm running the following code on Ubuntu 10.10, using OpenJDK 1.6.0_18: package mypkg; public
I'm compiling my code via the following command: icc -ltbb test.cxx -o test Then
The following code prints different results on 32bit and 64bit systems: #include <stdio.h> void
I'm having problems when trying to compile the following code: I first tried compiling
the following code: @Retention(RetentionPolicy.RUNTIME) @Target( { ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE }) @Constraint(validatedBy = { MinTimeIntCoConstraintValidator.class,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.