Java: Accessing Windows files from Linux machine
To access windows directory you should mount windows shared directory to your linux server.
See https://wiki.centos.org/TipsAndTricks/WindowsShares
After this you'll be able to use this windows directory as a local linux directory.
What is the best way to find the user's home directory in Java?
The bug you reference (bug 4787391) has been fixed in Java 8. Even if you are using an older version of Java, the System.getProperty("user.home")
approach is probably still the best. The user.home
approach seems to work in a very large number of cases. A 100% bulletproof solution on Windows is hard, because Windows has a shifting concept of what the home directory means.
If user.home
isn't good enough for you I would suggest choosing a definition of home directory
for windows and using it, getting the appropriate environment variable with System.getenv(String)
.
connecting to shared folder in windows with java
You should use SmbFile and NtlmPasswordAuthentication from JCIFS. Here is a simple piece of code to show you how to do :
String url = "smb://yourhost/yourpath/";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null, "user", "password");
SmbFile dir = new SmbFile(url, auth);
for (SmbFile f : dir.listFiles())
{
System.out.println(f.getName());
}
Related Topics
Add Buttons to Tabs and Tab Area Javafx
When Exactly Is It Leak Safe to Use (Anonymous) Inner Classes
How to Parse a Dynamic JSON Key in a Nested JSON Result
Replacing a Fragment with Another Fragment Inside Activity Group
How to Return an Array from Jni to Java
Using Static Variables in Android
Differencebetween List and Arraylist
Custom Listview Click Issue on Items in Android
Iso 8601 String to Date/Time Object in Android
How to Unzip Files Programmatically in Android
Hiding Strings in Obfuscated Code
Convert JSON Array to Normal Java List
How to Check If an App Running on Android
How to Compare Two Double Values in Java
Can't Run Program with Processbuilder, Runs Fine from Command Line