File Paths on windows and unix

Hi
I believe I read that when specifiying file paths in java, this is one aspect which is not platform independent. So if you develop something on windows which uses file paths if you wish to run it on unix you will need to change the syntax pertaining to the path. Is this correct?
Cheers

Well, generally file paths on unix and windows are very differently arranged, so it's actually fairly unlikely you'd want the same paths. Genarally files are either resources, best accessed with getResource/getResourceAsStream or they ought to be variable, perhaps stored in configuration (it's well worth getting to know java.util.prefs.Preferences).
And I usually find that if I'm dealing with a directory heirarchy relative to some base directory the two parameter File constructor is cleaner than mucking about with path separators.

Similar Messages

  • Remote file transter to windows and unix scp?

    Hi,
    I have to develop a new software component for a change managment. This component runs on a application server (based on windows 2003) and must copy or excute files on unix and windows. For unix copy I use ftp class of Ant. For windows (from one domain to another). I would like to use Scp but I do not know how I have to build my connect string for an windows domain.
    I try to test a connection und get a error �connection refused�.
    try {
    scp = new Scp();
    Project project = new Project();
    scp.setFile("C:/temp/test.txt");
    scp.setTrust(true);
    scp.setTodir("test:[email protected]:/D:/temp/");
    scp.setProject(project);
    scp.execute();
    catch (Exception exception) {
    exception.printStackTrace();
    om.jcraft.jsch.JSchException: Session.connect: java.net.ConnectException: Connection refused: connect      at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:187)      at com.hannover_re.ct.test.TestCommandsExecutor.testCopy2(TestCommandsExecutor.java:310)      at com.hannover_re.ct.test.TestCommandsExecutor.main(TestCommandsExecutor.java:41) Caused by: com.jcraft.jsch.JSchException: Session.connect: java.net.ConnectException: Connection refused: connect      at com.jcraft.jsch.Session.connect(Unknown Source)      at com.jcraft.jsch.Session.connect(Unknown Source)      at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:180)      at org.apache.tools.ant.taskdefs.optional.ssh.Scp.upload(Scp.java:249)      at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:176)      ...
    2 more --- Nested Exception --- com.jcraft.jsch.JSchException: Session.connect: java.net.ConnectException: Connection refused: connect      at com.jcraft.jsch.Session.connect(Unknown Source)      at com.jcraft.jsch.Session.connect(Unknown Source)      at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:180)      at org.apache.tools.ant.taskdefs.optional.ssh.Scp.upload(Scp.java:249)      at org.apache.tools.ant.taskdefs.optional.ssh.Scp.execute(Scp.java:176)      at com.hannover_re.ct.test.TestCommandsExecutor.testCopy2(TestCommandsExecutor.java:310)      at com.hannover_re.ct.test.TestCommandsExecutor.main(TestCommandsExecutor.java:41) Process exited with exit code 0.
    Is it the right way to use SCP? How can I realize a solution for my project?
    Please help :-)
    Thank you for your help.

    Well, generally file paths on unix and windows are very differently arranged, so it's actually fairly unlikely you'd want the same paths. Genarally files are either resources, best accessed with getResource/getResourceAsStream or they ought to be variable, perhaps stored in configuration (it's well worth getting to know java.util.prefs.Preferences).
    And I usually find that if I'm dealing with a directory heirarchy relative to some base directory the two parameter File constructor is cleaner than mucking about with path separators.

  • File Path for Windows and Linux

    hi can any one give solution how to implement code for odi file copy .
    i am using Same Code for Windows and Linux
    OdiFileCopy "-FILE=#Var_Lookup_File_Path \ Employee.csv" "-TOFILE=#Var_Lookup_File_Path_Backup\Employee.csv" "-RECURSE=NO" "-OVERWRITE=YES" "-CASESENS=NO"
    the problem of above code is
    it is working in windows but my Prod is Linux environment.
    in linux \ not works.. / will work
    please suggest how to concatnate variable and file without' \' '/'

    Thanks Phani
    i think in OS command also we may give path like #variable\File Name.
    So how it will replace \ with / in Linux.
    Could you give code for my Scenario..
    Thanks for helping

  • Webutil usage on Windows and Unix clients - Host and Temp dir issues

    Hello,
    I am in the process of writing a Forms application which makes use of WebUtil to handle the uploading and downloading of files, as well as launching the files on the client PCs. The code below is my current 'Launch' program which works great in a Microsoft Windows environment. It gets the TEMP directory location, builds a file name, downloads the file to the TEMP directory and uses the Host command to launch the file.
    PROCEDURE Launch_DB IS
    l_directory varchar2(200) := client_win_api_environment.get_temp_directory(true);
    l_success boolean;
    BEGIN
    :file_block.full_file_name := l_directory || '\' || :file_block.file_name;
    l_success := webutil_file_transfer.DB_To_Client_with_progress
    (clientFile => :file_block.full_file_name
    ,tableName => 'FILES
    ,columnName => 'FILE_DATA'
    ,whereClause => 'ID = ' || :file_block.id
    ,progressTitle => 'Download from Database in progress'
    ,progressSubTitle=> 'Please wait'
    if l_success then
    WEBUTIL_HOST.NONBLOCKING('CMD /C "' || :file_block.full_file_name || '"');
    else
    exception
         when others then
         message('File download failed: '||sqlerrm);
    END;
    My problem is that I've just discovered that there's a new group of users that will want access to these forms, and they're using non-windows machines - mostly Solaris and Linux. As such, I have these problems:
    - " client_win_api_environment.get_temp_directory " is a Microsoft Windows specific function. Is there any way to determine a temporary storage area on a Unix machine?
    - " WEBUTIL_HOST.NONBLOCKING('CMD /C "' || :file_block.full_file_name || '"'); " - CMD is Microsoft Windows specific function. What should I do to launch a file from Unix? (Sorry, my Unix skills are pretty minimal).
    - I'm guessing that I'll need to determine the operating system so that I can use different methods to determine the TEMP dir, and to execute the HOST command. Assuming that Microsoft Windows and Unix variants are the only OS's that I need to provide access to, what is the best way to determine the client environment ( eg. IF UPPER(WebUtil_ClientInfo.Get_Operating_System) like '%WINDOWS%' THEN ... ELSE ... END IF; ) . I only have access to Windows XP for testing so I don't know what values "WebUtil_ClientInfo.Get_Operating_System" will return for any other OS.
    Thanks in advance for any assistance.
    Regards,
    Michael.

    Hi,
    as far as launching the file goes, if teh program that runs the file exist on teh local computer, you can use teh host command in webutil to access teh program and file. CMD is what you use to open teh command line on windows, but the host command is supposed to work on the UNIX client as well.
    For the temp directory, you have two options
    The short term option: Pass the temporary directory name as a user variable to Forms when starting the application. This can be user specific if adding this information to the URL using teh otherparams parameter
    The longterm option: Log a TAR with Oracle customer support to add a function to teh getClientInfo function that retruns the temporary directory for the authenticated user.
    Frank

  • String.getBytes (java) o/p different in Windows and Unix

    Hi,
    I was trying out the following code, which gives me a byte array from a
    String object.
    byte[] bytArr = null;
    bytArr = <String object>.getBytes("UnicodeBigUnmarked");
    System.out.println(bytArr.toString());
    The output is different in Windows and in Unix. The assumed that the reason could be because Intel architecture is based on little_endian so the difference in output. I changed the code to the following
    bytArr = <String object>.getBytes("ISO8859_1");
    and then ran the class file by using "java -Dfile.encoding=ISO8859_1" so that the toString can also take the character encoding of ISO8859_1 rather than using the platform dependent one. Still the result is different in Windows and Unix.
    What could be the reason for this? How can I correct this ? Any help in this regard is welcome.
    cheers
    kk

    Hi Sabre150,
    Thanks for the suggestion, it worked. Both the o/p shows the same if I use System.out.println(Arrays.toString(bytArr));
    I am assigning full points to you. Thanks a ton for the help.
    To end with I have one more question, the method Arrays.toString is introduced from jdk1.5, so if I want to use jdk 1.4 what should I use instead of Arrays.toString ?
    It would be great if I can get this answer.
    cheers
    kk

  • Compiling reports6i on Windows and Unix

    Hi Friends,
    I'm compiling reports6i on windows by opening the browser window online. But to my confusion when I run and save the report program, I only see the .rdf extension of the file. I just thought the executable version is .rep , so I thought I will see also this file type. My question is can the report program run without the .rep extension file?
    Thanks

    Thanks Hussein,
    But I got this script from metalink > How to compile reports on windows and unix in batch mode:
    For Windows Reports 6i
    ===============
    REM WINDOWS COMPILE REPORT
    ::compile_report.bat
    cls
    Echo compiling Report .....
    for %%f IN (*.rdf) do RWCON60 userid=scott/tiger@v817 batch=yes source=%%f
    stype=rdffile DTYPE=REPFILE OVERWRITE=yes logfile=log.txt
    ECHO FINISHED COMPILING
    For Unix Reports 6i
    ============
    #UNIX COMPILE REPORTS
    #compile_rep.sh
    for i in `ls *.rdf`
    do
    echo Compiling Report $i ...
    rwcon60 userid=scott/tiger@bs817 batch=yes source=$i stype=rdffile
    dtype=repfile overwrite=yes compile_all=yes
    done
    =======
    I'm only concern with the unix output....is it ok if I have both file extensions? (.rdf and .rep)
    Another concern is are the program name case-sensitive? I know unix is case-sensitive unlike windows.
    So if I have a program name APXDCDFO.RDF , is it the same with
    APXDCDFO.rdf or
    apxdcdfo.RDF or
    apxdcdfo.rdf
    Thanks a lot

  • How to find cd rom drive in windows and unix platform using java program

    Hi,
    I am having the requirement of finding the cd rom drive
    using java program. I do not know the label and which
    one is the cd rom drive. also I want to know how many
    cd rom drives are there on my system. I want the solution
    for windows and unix platforms.
    If have any suggestions please mail to [email protected]
    Deepak

    Ughhh.. I had the same problem with multi platform file-system detection
    First off - Unix.
    Do you know for sure you have all your drives mounted?? This could be a big problem because java will not see unmounted drives... So you can scour thru your /etc/fstab to find out which drives are available... or you can mount all and show roots... (Yuck!)... You've got timeouts and all sorts of things to worry about...
    I would then shy away from the java.io.File.listRoots() on unix and rely on parsing your fs file. If a user would like to see the medium in the drive. Do a Runtime.exec and mount the drive, then you can grab the filesystem by wrapping it in the java.io.File object. ( NOTE - this will hold well for your NFS mounts as well which might be buried under other FS. So you now have detection for that as well. ) Labels are also noted in this file. Let me know if you don't know the difference between mtab and fstab....
    Second - Winders.... Corney but I love saying that.
    The listRoots is a good solution. As others have said CD-ROMS will not be writable. Use a combination of getName and getPath to decipher the label and mount point.
    Hope this helps!

  • Problem in reading the excel file path in WINDOWs machine from UNIX environ

    Hello friends,
    My requirement is to read each row of the excel sheet and sent that row to the database. I have implemented it by using jxl and apache poi framework. locally in my WINDOWS machine it is working fine..
    But when i deploy the code in UNIX machine. My application runs on a Unix server , trying to read the excel file in WINDOWS environment. I am not able to retrieve the file path. for ex : C:\Documents and Settings\sabbanik\My Documents\KARUNAKAR\excel.xls
    I am getting error in this line
    workbook = Workbook.getWorkbook(filepath)
    Error message : input file not found.
    Thanks in advance..

    You said: I am getting error in this line workbook = Workbook.getWorkbook(filepath) >
    Based on this, I will assume you are trying to use OLE to access information about the Excel file. As mentioned by Andreas, your code will be executing on the server (Unix) and since Excel isn't on the server (and cannot be) an error will result. OLE can only be used in Windows environments (client or server). To access client side OLE calls and content, you need a java bean and Excel installed on the client machine. Oracle provides WebUtil as an option to writing your own Java Bean. To use this, you will need to be running Forms 10.1.2 or newer. Details can be found here along with a demo:
    http://www.oracle.com/technetwork/developer-tools/forms/webutil-090641.htm

  • Common URL format for sharing file paths between Mac and Windows?

    Hi -
    I have to integrate several Macs into a Windows environment. We need to be able to copy and paste file paths to share between all machines. Is there a common URL format that can be used between the platforms?
    On Windows, I have:
    \\server\share\file
    On the Mac:
    smb://server/share/file
    Thank you for your help,
    Steve

    On Windows you have what is known as a "UNC".
    On the Mac, you have a "URL". It starts with the protocol to use "smb" then gives the path to the item using standard conventions.
    UNC is Microsoft mainly.
    The only way I know for Windows to use a URL is with an application like a web browser or ftp client.
    On the Mac, you can use UNCs but they must be modified as follows.
    In Terminal:
    smbclient \\\\servername\\sharename\\filename -U username
    And enter a password if prompted.
    Notice that you must double up the slashes. This is due to how UNIX shells treat the backslash.
    You will connect to the share, but it will only be in Terminal.

  • Setting file permisions ,group permission on Windows and unix from java

    Hi
    i am trying to set up file permissions through java on unix and windows operation sysyem
    .I don't want to use shell scripts .
    thank you for your help.

    HI BIJ001,
    Thanks for reply.I am paling to use
    1)First i am detecting operating system
    2)if it is UNIX->calling unix scripts from JAVA
    2)if it is WINDOWS ->calling Bat scripts.
    But attrib command in windows does not support FIle Gropu permssion like unix(chmod 777 filename).
    Do yoou have any experience in .bat sctipts on file permission.
    Let me know .Again thank you for reply.

  • Difference in performance of SBA between Windows and Unix

    Hi,
    I am using a  MSF routine which uses SBA to recursively search a sysbld suprerblock and its children to find a specific type block (in this case a ucb). It works fine on both Windows and Solaris Xmath. However, for very large models, there is a huge performance difference. I ran the algorithm on a model containing around 1000 superblock and 10000 blocks. Under Solaris (7.1.5) it takes around 30 seconds while under Windows XP (7.1.6) it takes more than 8 minutes.
    Any thoughts on the reason behind this difference.
    Thanks
    Farshid
    P.S. The MSF file is attached
    Attachments:
    finducb.zip ‏1 KB

    I'm aware I may get some flack for this statement.^^^Some. <grin>
    I'll give you the counter-argument. Those Unix shops with incredibly stable environments? Have you done a count of actually used applications? The ones that mimic the business' current needs? The ones that reflect the business', uh, business? Perhaps it's just the clients I interact with, but those often have a mixture of "dead" apps in with the live ones. I rarely see that with Windows and yes, the app count is sometimes crazy high on the Unix side -- certainly beyond what EAS can comfortably navigate (I was on a 9.2 environment once that had 200+ apps -- Shared Services was essentially broken at that site, but so was 9.2 in general.)
    Anyway, I've observed that IT tends not to do a terribly good job of producing flexible analytical applications. They are very good at stability, sustainability, security, and all sorts of other things Essbase (and other, especially transactional) environments must have. Until they become fossilized in their SOPs, their policies, and their requirements. At which point a different transformational technology that the business can control pops up -- heard of TM/1 lately? I am super curious (for all kinds of obvious reasons) to see where my beloved Essbase ends up in a few years.
    I'm not coming down on either side, just saying that I've seen this play out multiple times since the mid-1980s. While both sides have their merits, at the end of the day, if a super well maintained environment is just a monument to IT's ego, it's worthless. And yes, I have seen Windows environments that are just that.
    Regards,
    Cameron Lackpour
    Edited by: CL on Jul 12, 2011 9:54 AM
    Smiley faces no longer work. Why oh why oh why?

  • STMS configuration windows and unix

    Dear guru,
    We had a two system landscape.Dev system in windows and prd system in unix.
    We are configuring the STMS . We take domain controller in prd system.The common transport Directory in Prd system that will map to dev system .There is a error messge, the dev system cannot access the bin(profiles) and .cfg files.
    Kindly provide the solution.
    regards
    guna

    Yes I created a samba/CIFS.
    The security levels is share .I created a same user in windows system with permisson <sid>adm user privilages.
    In the Unix system acess is working fine.but windows the file system is not acess by the TMSadm user.
    when the stms configuration the profile file will be access by the tmsadm and write in the profiles (/bin).that process not done by the windows server.
    guna

  • FIle path between iTunes and music files broken

    Somehow I've managed to lose the file path connecting my songs on an external hard drive with iTunes. I've checked the advanced aoptions to make sure that iTunes is pointing to F: (instead of C:) but no dice.
    Obviously I can go through and reconnect them all individually but for 16,000 songs that's not an option. I also don't want to reload the song files (by opening them directly from the drive) and lose all my play count information.
    I've had this happen before when upgrading PCs or when the EHD was renamed and been able to fix it but this time nothing seems to work.

    Yes it has. I recently changed from laptop to PC and managed to load iTunes on PC, copy across playcount and album artwork information and have the EHD connected and showing the correct pathways. Everything was working fine for about 3 days. When launching iTunes a couple of days ago, it asked me to go through the setup screens again (which I did) and since then the file paths have been missing. I've been into the xml file of the iTunes library and it shows everything pointing to the default c: drive location. This may be because I read that consolidating the library (under the advanced tab) would help but it didn't.

  • How to create a button to get File Open popup window and select a file

    Hi,
    I have an applet that contains Browse button. When user clicks on that, a File Open popup window should be displayed to enable user to select the input file. This file path should be given back as parameter.
    How to do this? I have tried using LoadFileData but not able to get the desired result.
    Any pointers would be helpful.
    Thanks,
    Lalitha Dandibotla

    Do you need only the path or also the file back into Siebel?
    If you need both, the have a look at any attachment applet, that will give you a good start.
    Are you using Siebel in High Interactivity (HI) Mode or Standard Interactivity (SI) Mode?
    If you are in SI Mode have a look at the html type
    <input type="file">
    http://www.w3.org/TR/html401/interact/forms.html#h-17.4
    Axel

  • TS3212 i saw the file download security window and did enter run, it only gets so far and then a window pops up that says there is a problem with the download and can't install.  what do I do?

    I did see the security download window and entered "run", but it only got so far and a window popped up saying "problem with download, can't proceed".  What to do?

    This happened to me, too. If I remember correctly, I had to set wither iTunes or my computer to download files one at a time instead of all at once. I don't remember how I set it to do this, though. I also remember that I had to delete the files and downloads and restart them all after I did this. Sorry I couldn't help more.

Maybe you are looking for

  • DMS-Object link to business partner (ISU-Module) required. Plz help.

    Hi all, I require to give an object link from DMS to Business partner of ISU module t code BP. So checked up in SPRO- Control data- maintain key feilds, & i found that BUT001 is the transparent table which is used here. so i inserted the same in obje

  • HT4559 How do I get a list of the 200 new features for iOS 5

    How do I get lists of the apparent 200 new features of iOS 5 for some reason I cannot find any in support on this website or anywhere! Also I want a description of what each feature does. Mainly in safari but I'm getting a bit suspicious if any of th

  • Sales Employee Details Based on Invoice

    Hi, Based on Invoices i need to bring the sales employee details. sales employee is present in Sales Order as Partner Function. can any one help me on this.

  • Query Trip Data with Zero Amount

    Dear all, I have requirement to retrieve every trip record which has zero amount in its total cost. It didn't work when I use TCode S_AHR_PH0_61016401 (General Data Trip) for this query purpose. I also took effort to make my own query definition usin

  • Cluster and processors

    Hi, I have some questions about the number of processors regarding clusters. For example, if i want to install rac on 2 nodes, on 2 different machines, does it mean that i have to buy a license for 2 processors ? In the same way, if i want to install