• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic