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 6336945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:09:27+00:00 2026-05-24T19:09:27+00:00

I am having enormous difficulty writing to a simple text file in Java. Every

  • 0

I am having enormous difficulty writing to a simple text file in Java. Every search I’ve done for the IO exception I’m getting is turning up plenty of suggestions, but none of them apply to this situation.

Here is my project structure:

MyEclipseProject/
    src/
        com.myprogram.utils
            MyProgram
    bin/

And my code for MyProgram.java:

package com.myprogram.utils;

import java.io.FileWriter;

public class MyProgram
{
    public static void main(String[] args)
    {
        FileWriter oWriter = new FileWriter(new File("logs/system.log"));
        oWriter.write("This never gets logged because JRE can't find the file");
    }
}

The exception message I’m getting states: logs\system.log (The system cannot find the path specified).

The first time I tried, I did so without having first created the logs/ directory and its subsequent log file. My understanding was that, if Java couldn’t find the file, it would create it for you.

I have now placed a logs folder – with a blank system.log file – inside: (1) my project root (MyEclipseProject), (2) the src/ folder, (3) the src/com.myprogram.utils package, and (4) the bin folder, and I am getting the same exact error. I’m wondering: could I have an OS/persmissions thing going on? Could my app be trying to create the folder and log file but be getting denied permission to do so by Windows 7? If so, what do I do?!?!

If not, where in tarnation do I place logs/system.log???

Thank you for any clarity to this!

  • 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-05-24T19:09:28+00:00Added an answer on May 24, 2026 at 7:09 pm

    To see which directory you are in, add the following print statement:

    System.out.println(new File(".").getAbsolutePath());
    

    This will tell you where you should create the logs directory.

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

Sidebar

Related Questions

Having a problem getting a TreeView control to display node images. The code below
Having difficulty articulating this correlated subquery. I have two tables fictitious tables, foo and
Having just upgraded to iOS 4.1 (Xcode 3.2.4) I am getting warnings when using
Having some trouble getting a JSON feed to load from my site. I'm starting
Having a problem with git-based gems. gem file contents: ... gem 'spree', :git =>
I am having enormous problems applying my styles to the Breadcrumb NavXT plugin. When
Having some difficulty using a variable within an ajax() function. I know it is
Having been a PHP developer on LAMP servers for quite a while, is there
Having a heckuva time with this one, though I feel I'm missing something obvious.
Having worked with Classic ASP for about 2 years now by creating a few

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.