简体   繁体   中英

Attempting to access Shared files on Windows Server from Java program running in UNIX

I'm currently trying to create a Java program which will automate reports. I have only one issue that's stopping me (so far) and was wondering if anyone tried this before and know a work around.

My Java program is successfully running locally using NetBeans on my Windows XP Professional PC using the following file paths: File filex = new File("\\\\10.78.0.99\\\\ITX1DATA\\\\CLOSET\\\\DClean\\\\MPHMETRICS\\\\MPH Daily Volume Report.xlsx");

FileInputStream fstream = new FileInputStream("\\\\10.78.0.99\\\\ITX1DATA\\\\PROVIDER\\\\DClean\\\\MPHMETRICS\\\\'PS.PRIME.NPI.DAILY.METRICS'");

FileOutputStream out = new FileOutputStream("\\\\10.78.0.99\\\\ITX1DATA\\\\PROVIDER\\\\DClean\\\\MPHMETRICS\\\\MPH Daily Volume Report.xlsx");

However, when I logon to the UNIX Dev server: (Echisxtlmapp12 - 10.131.13.36) and I: 1) Switch file paths to use Java version 1.6 which works. PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java6/jre/bin:/usr/java6/bin:/usr/java131/jre/bin:/usr/java131/bin:$PATH ; export PATH

2) Do a change directory to my program directory cd MphMetrics

3) Run the program java -jar MPHDAILY.jar

I get the error message: Error: \\10.78.0.99\\ITX1DATA\\PROVIDER\\DClean\\MPHMETRICS\\MPH Daily Volume Report.xlsx (A file or directory in the path name does not exist.)

I'm able to successfully ping the server ping 10.78.0.99 which contains the shared files from the UNIX server.

It would make sense if I ran it locally and it did not work, but it works locally w/o issue.

Thought I run it by you to see if anyone tried running a Java program this way using network drives. Ultimately I will be creating a Unix Shell script of Daemon service which will run 7 days a week creating MPH report.

Your best bet is to use a library which is able to "talk Windows".

And there is one: JCIFS , by the good folks at Samba. Link to javadoc here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM