What path to use to access network files from Java app running on Mac

I have a Java app running on a Mac with OS X that I'm using to check for files that exists on Windows servers within our network.
Using a path like /Volumes/<Share>/ works because I've already connected to the drive using Finder. If I try to use a fully qualify the path with "smb://<Server>/<Share>" then my app doesn't see anything. Is there any way that I can get Java to connect to a directory without first having mapped or made the connection via some external tool like Finder?
Here's the code I'm testing with:
package FileImports;
import java.io.File;
import java.util.Arrays;
public class Dir {
static int indentLevel = -1;
static void listPath(File path) {
File files[];
indentLevel++;
files = path.listFiles();
if (!(files == null)){
Arrays.sort(files);
for (int i = 0, n = files.length; i < n; i++) {
for (int indent = 0; indent < indentLevel; indent++) {
System.out.print(" ");
System.out.println(files.toString());
if (files[i].isDirectory()) {
listPath(files[i]);
indentLevel--;
} else System.out.println("Directory not accessible!");
public static void main(String args[]) {
// this path works where <share> = the directory where my files exist.
listPath(new File("/Volumes/<share>"));
// this path returns a null result in files
// listPath(new File("smb://<Server>/<Share>/"));
Thanks,
Alex
Edited by: agates on Sep 25, 2008 11:14 AM

agates wrote:
Thanks for the response. I'll have to dig a little deeper into JCIFS. It looks like it would work great windows to windows. I haven't been able to find in the documentation where it would work on OS X without having to mount the targeted file system first. Has anyone had success creating a connection to a windows file system from OS X with JCIFS?Since jCIFS is written in pure Java and implements the entire SMB/CIFS protocoll on it's own it doesn't require any support from the OS (apart from a normal JVM runnig). Thus it should work exactly the same in OS X and Windows (and Linux and Solaris and ...).

Similar Messages

  • Deleting files from Java app in XP

    Greetings --
    I'm currently developing a standalone app that, among other things, needs to read an image in from a remote server and somehow translate it back into an image file. Right now, I'm reading the information in and saving it to file so that I can manipulate it -- but when my program is done, I want to "clean up" by deleting this image file. I haven't been able to find a good way to delete a file from Java - is there a way, even by somehow invoking the old DOS "del" command? Thanks in advance!
    Yours,
    Cheryl/muppetaphrodite

    Simplest way for a file:
    // Assuming String fileName;
    new java.io.File(fileName).delete();
    If you want to delete a directory recursively, you'll have to write a recursive method to open a directory using File.listFiles() and checking File.isDirectory() as your guides. Remember to walk a directory completely first, deleting everything under it, before deleting the directory itself.

  • Error accessing PDF files from Java

    In CF7, I have a routine that opens submitted PDF files
    through Java to do some manipulation. Similar to CF8 PDF
    manipulation, but more complex. In almost all cases, it works fine,
    except two.
    For one, a submitted PDF was corrupted somehow -- I can't
    even open it with Acrobat. On the line:
    "reader=pdfReader.init(pdfFile);" this returns the error below.
    This is expected. But with a couple other PDF's, that do open fine
    in Acrobat, I get the same error. I even re-saved the PDF file to
    different versions of Acrobat, but java still complains. Any ideas
    what causes this, or what to do to prevent it?
    Does anyone know if CF8 java processing does anything
    different here that would prevent problems like this?
    reader=pdfReader.init(pdfFile);
    An exception occurred when instantiating a java object. The
    cause of this exception was that: .
    From the stack trace:
    java.lang.reflect.InvocationTargetException
    at
    sun.reflect.GeneratedConstructorAccessor48126.newInstance(Unknown
    Source)

    It does always happen after having successfully done others,
    as these are in a list of about a dozen that it processes at a
    time... but it is always consistent - it does all the others fine,
    and then always breaks on these particular PDF files, time after
    time, day after day. So it's not a random thing that comes and
    goes.
    The 3rd party tool is the one that's "built-in" to CF,
    com.lowagie.text.pdf.PdfReader. This is all on a shared host, and
    so I wouldn't have access to installing alternatives.

  • Accessing DLL files from Java

    I have a problem with Java, and the problem is that I'm trying to call a DLL file declared by C++ only but without a support for Java programs, is what I'm aiming for going to be available by using the rundll32.exe file.
    Note: I'm trying to use the (skydll.dll) file for controling skystar2 DVB card.
    Message was edited by:
    JZoro

    You cannot directly call a DLL from Java unless the DLL exposes entry points that are compatible with the JNI calling conventions.
    For example a Java class calling a native function like below:
    class Arguments
       private native void setArgs (String[] javaArgs);
       public static void main (String args[])
          Arguments A = new Arguments();
          newArgs[] = A.setArgs(args);
       static
          System.loadLibrary("MyArgs");
    }Needs a DLL entry point with the following signature:
    JNIEXPORT void JNICALL
    Java_Arguments_setArgs (JNIEnv *jenv, jobject job, jobjectArray oarr) {Notice that the first parameter of the method is of type JNIEnv and the second can be either a reference to a class or Java object instance.
    Jacques Gonzalez
    J4SOFT

  • How to access physical files from java platform

    Hello All,
    We have one JDE Word Writer program, which export the order master data in the DB2/400 Physical files.
    We want to access this data from our java program (reside on windows platform). I am wondering how we can do that. I got one hint that can be accessed by ODBC connection. But I am unable to get the correct ODBC driver. I am looking for correct driver to access the data.
    If some one has done this already, please help me. Or suggest me any alternate way.
    Dinesh

    Can use File class to write code to examine and manipulate file.
    Tutorial: http://java.sun.com/docs/books/tutorial/essential/io/file.html

  • Drag and Drop file FROM Java app TO native desktop

    I'm a litte new to Drag and Drop. After a few days of looking around I've been through enough examples to copy and paste some skeleton code and get it working in my own application.
    What I haven't gotten any answers to (after searching on google, newsgroups, and here) is if it's possible to drag something from a Java app to the desktop or file browser, and have java create a file there.
    I know you can drag text to native apps, so I was wondering if you could make a Transferable object that's different than StringSelection(), like a file stream or something.
    Thanks,
    Tristan

    Tristan,
    I am stuck in the same place. Perhaps we could work on this together.
    I am trying to drag a single item from a JList to a text editor, Word, etc. I have two problems:
    1) I can't seem to get just the item in the JList to drag. It wants to drag the entire JList component.
    2) How does one define the remote application as the drop target? Have not found any examples either.
    Is the drop target actually the system clipboard?
    Rp

  • I cannot access network files from Captivate 6 Trial

    I downloaded the trial version of Captivate 6 for evaluation. My company stores our data on a server. When I try to open a file Captivate does not have an option to go to the server, which in this case is set up as my Z drive. All my other Adobe programs work fine. We have a much, much older version of Captivate that is on another computer and it works fine. The trial version will open any files I have on my laptop but not from the network. I can't even see them in the Captivate open file menu. If I open the folder where the files are stored and right click and "open with" I can get the file to open, howevr I get an error saying that some of the features may not function well because I don't have administrator privilages and I should close and open the program with "run as administrator". Is there a setting that I missed? If it is a case where all the files must be stored locally for Captivate to see them, this will not be a viable option for our company.
    I run an Alienware M15x Running Windows 7 64bit.
    Any help or advice would be greatly appreciated.

    As far as the replay function. Captivate does not have a simple button that allows for a slide to replayed from the beggining should a person need to. For example (just in case my explination is not very good), we have slides that include animations that were created in Flash. The slides also include audio. There is no simple way, at least not on that is listed anywhere that we can find, and we have searched for days, by where you can simply insert a button that will start the slide over and replay the animation as well. I mean a "simple" solution. It can be done with coding and manipulation of the flash files, and the creation of our own buttons. This method is just more work than I would expect for what should be a very standard feature. Any good, anc Captivate is by no means a horrible program, and I am still on the upside of the learning curve here, any good learning course allows for the student to replay a slide just in case they need to hear something twice or four times. If you know of a very simple way of doing this, there are tons of folks out there that would love to know. On Adobe's own forums the solution most suggested was to insert a blank slide before the slide animation and have your button go to the previous slide. We did find a way to accomplish this but it takes a bit of coding and the use of a widget to do. The issue is that it is not consistant. Sometimes it works other times it does not. This may be because of the network issues with Captivate. I am trying to get it downloaded to a desktop and see if that will solve the problem,  but the download has failed so I won't know for a while yet.
    For the network thing, I don't doubt what you say at all, as far as the program needed the files locally. It just seems, especially in the year 2012 (almost 2013) that this is an issue. I have the entire Adobe CS6 suite as well as CS4 Creative Suite and have not had a single issue with any one of those programs funtion with the files stored on a different machine. Agreed, if we want to use Captivate we must use it the way you have suggested, it just seems like they would have designed it so folks could work over networks easier. It is not a matter of NOT being Willing to work this way, it is a matter of needing to be more efficiant and share data between several folks working on the same projects.
    Thanks again for your help.

  • What do i need to access my files from any internet connection

    I'm a bit confused, i've found some good videos on youtube on setting up the server but can't get the file shareing to work (of course the only reason i got the server). Some have told me i need a dyns routing service, so i used machighway.com but i still could not connect to my server from any internet conection outside of my home wifi. Now i've been told that i need VPN to be able to do that. So i'm hoping that someone can help clear this up and point me in the right direction. I can connect to the server using my Mac book air over my wifi (using an airport extreme). please help, i've had this server for half a year and have yet to be able to use it for what i intended.
    (i upgraded the server to OS X Mountan Lion, and upgraded the app to OS X Server)

    Here's how I did it.
    -Open a free account at no-ip.org
    -Download their app, change your server's hostname to the hostname you selected for your brand new no-ip.org account. Ideally you'd perform this step on a clean install of the Server since changing the hostname can mess a lot of the services up.
    -You'll be able to tell it's working by enabling the Websites service and visiting your new no-ip.org hostname in a web browser. You should see the default server page.
    If you have follow up questions for me, I don't read this forum much but I am on reddit a lot and I'm trying to start a new subreddit for mac servers: http://reddit.com/r/macserver . Post a thread on there.

  • What the best way to create XML files from JAVA application?

    Hi to all,
    I need to edit and to create new filex in format of xml. I know to parse, but what would be the best way to do:
    1. - Create new file, create like simle text file, or there is some clases that know to do it in more simple way
    2.a - Edit XML file, to take some data and add it to the XML in the place I want to.
    2.b - Also Edit, but not to add fields, just update some of them.
    Code examples or links to samples woul be welcomed.
    Best regards, Nick.

    I have tried working with XML directly using the Java classes but this was a pain. I then looked at DOM4J and JDOM and found JDOM easier to use.

  • Accessing .properties file from java code

    Hi,
    I want my java code in a Tomcat Web Application to access values in a custom .properties file.How can i do it.
    Any sample code / suggestions welcome.
    Thanks
    Vignesh.

    ResourceBundle vResourceBundle = ResourceBundle.getBundle("database", Locale.ENGLISH);
            sDriverName = vResourceBundle.getString("database.DriverName");
            sDbURL = vResourceBundle.getString("database.DriverUrl");
            sDbUser = vResourceBundle.getString("database.UserName");
            sDbPasswd = vResourceBundle.getString("database.PassWord");Where "database" is the name of the property file. ie., database.properties.
    the content of the database.properties file
    # Properties to access dabase                 
    database.UserName = scott
    database.PassWord = tiger
    database.DriverName = oracle.jdbc.driver.OracleDriver
    database.DriverUrl = jdbc:oracle:thin:@nn.nn.nn.nn:port:orartgnull

  • How to use a VB dll file in java

    hi,
    i am working on college project,In this output of calculation is not matching with college site .So any one can tell "how to use or combine a VB 'dll' file in java?".so that i can use VB 'dll' file in java to get right Output.
    If possible write code or send it to "[email protected]"
    Thanks
    Ravi kapani

    Did you try Google? And no, there is no native support for accessing .dll files from Java. That said, take a look at JNI.

  • Accessing XML files through java

    Can any one explain me the easiest way of accessing XML files from Java.

    Hi,
    If you want to only access the XML file, use the SAX parser It will be very easy to handle and identify the element and value.
    else if u want to change the XML value also, then better go with DOM, Which has very good flexiblity.
    use according to the need, let me know if any help is required......
    With Cheers
    PrasannA

  • What is the best way to use wi-fi to transfer pdf files from an ipad to a mac mini, not using an internet, just wi-fi.

    What is the best way to use wi-fi to transfer pdf files from an ipad to a mac mini, not using an internet, just wi-fi?

    If the Mac use Lion (10.7) you can use Airdrop for that.
    With Mac's not using Lion you may set up a computer to computer (ad hoc) connection.
    How to --> http://docs.info.apple.com/article.html?path=Mac/10.6/en/8339.html
    Lupunus

  • HT2476 After updating to OS X Mountain Lion, there is a password locked pdf document in the Downloads Stack. Does anyone know what password is required to access this file?

    After updating to OS X Mountain Lion, there is a password locked pdf document in the Downloads Stack. Does anyone know what password is required to access this file?

    Hello, if your install disk is locked (I assume with FileVault) there is no way to change the password. If it weren't locked there were at least two solutions. As far as I know, the only solutions now are:
    - contact your dad
    - erase and reinstall the OS X clean
    Let us know.

  • HT204382 what can I use to view flv files on my Mac with Lion?

    What can I use to view flv files on my mac running lion? I have tried several free ones like VLC & they play 4-5 seconds & quit?

    http://perian.org allows playback of Flash formats via QuickTime Player.

Maybe you are looking for