• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Writing a file in Mapped Network drive using java running as Windows service

 
Balaji Soundarajan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are trying to create a file in mapped network drive (Z:\VOL3) using java.The file is successfully created in standalone java application.But if the same java application ruuning as windows service then its throwing "system cannot find the path specified" error.
We have tried like File f=new File("Z:\VOL3");

Please help us resolve this issue.

 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's because by default, network mappings are user-specific. That means that the user that is running the service (usually "Local System") does not know about your Z "drive".
 
Balaji Soundarajan
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to achieve this?
Is there any way to change something to access the neetwork drive thru application running as service?

Please let us your comments.
 
Hobie Orris
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am experiencing the same problem. Another poster on this site got it working by
1. Changing the service credentials to user (system accounts don't have network privileges)
2. Changing the file path you are trying to access to a UNC (I changed mine from Z: to \\billthecat\store for example)

These were not sufficient for me. When I switched the service account to 'Admin' from 'LocalSystem' I got a pop-up telling me that Admin was granted the 'run as system service' privilege, but I am skeptical. I am using XP Home and I can't actually examine my real privileges. I am wondering if I need a different version of Windows to make this work.
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Running as a user (or as NetworkService) may only work when both computers are in the same domain, which won't be the case with XP Home.

A more complicated alternative is JCIFS, which doesn't use java.io.File, but would let you supply your own network username and password.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic