Results 1 to 5 of 5
  1. #1
    lime is offline Member
    Join Date
    Apr 2014
    Posts
    15
    Rep Power
    0

    Default Editing hosts (etc folder) file in Windows

    Hi, is it possible to edit hosts file in java program? I tried it but i'm getting "AccessDeniedException". I need to have permissions for it, but can i somehow set the permissions in java program for current user? thanks for explaining if it's possible.

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,358
    Rep Power
    6

    Default Re: Editing hosts (etc folder) file in Windows

    It would be pretty sad if you can bypass OS security just by writing some Java code, wouldn't you think?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    lime is offline Member
    Join Date
    Apr 2014
    Posts
    15
    Rep Power
    0

    Default Re: Editing hosts (etc folder) file in Windows

    Yes you're right. I didnt realised it, but it was because (i dont know where), but i downloaded an application which blocked the facebook webpage using the rewriting the hosts file because i remember i had to edit it manually back. It had to be written in another language. I have read some languages can edit these files in OS, does anyone know what?

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,091
    Rep Power
    4

    Default Re: Editing hosts (etc folder) file in Windows

    As long as you run your program as administrator you should be able to overwrite any file. As an ordinary user you will fail. Even then, if there's software monitoring the hosts file, you're screwed anyway.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  5. #5
    lime is offline Member
    Join Date
    Apr 2014
    Posts
    15
    Rep Power
    0

    Default Re: Editing hosts (etc folder) file in Windows

    Oh i know where was the problem. Avira antivirus was blocking the access to hosts file. Now it's working.

Similar Threads

  1. Replies: 1
    Last Post: 05-03-2013, 03:57 PM
  2. Replies: 0
    Last Post: 11-25-2012, 06:23 AM
  3. FileWriter editing hosts file Mac
    By danborgir in forum New To Java
    Replies: 2
    Last Post: 01-12-2011, 12:23 PM
  4. Access Linux shared folder from Windows OS
    By nitinpjairaj in forum Networking
    Replies: 3
    Last Post: 08-26-2008, 07:14 PM
  5. Replies: 1
    Last Post: 06-23-2008, 07:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •