Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filesystem mac/windows differences

Status
Not open for further replies.

stormbind

Technical User
Mar 6, 2003
1,165
GB
Hi,

I have a problem where my java app works on Windows but not Mac. The directory is the same, the files are the same, but on the Mac it says file doesn't exist.

It's a simple text file. There are no problems on Windows, and all related files are in the same directory on a network drive so there is no possibility of there being some overlooked difference between files.

Any suggestions?

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Harcoded path? Encoding problem? Maybe if you give us more details, error stack traces, code snippets ...

Cheers,
Dian
 
This is really simple stuff, I do not see how a code snippet helps in the slightest.

BufferedReade temp = new BufferedReader(new FileReader("file.txt"));
// works on windows
// cannot find file on mac

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
file.txt" doesn't look like a networked drive to me.

If you're passing UNC drive into it i'm not sure that the mac is able to use UNC mnenomic...
 
Add some debug to find out what the process's current working directory is :

File pwd = new File(".");
System.out.println("Current working directory is : " +pwd);

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I suspect you're not putting the file in the same place in both environments ...

Cheers,
Dian
 
It's a shared network drive. There is no oportunity for the files to change.

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Have you found out what the current working directory is for that process yet ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Hi sedj,

Add some debug to find out what the process's current working directory is :

File pwd = new File(".");
System.out.println("Current working directory is : " +pwd);

That was a good idea. It prints out:

Current working directory is : .

*shrug*

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
It the file is in a network drive, he must specify a valid path, the file cannot be in the current directory. Unless the program is also executed from a network drive, which I doubt.

Cheers,
Dian
 
The program is executed from the network drive.

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Just print:

Code:
pwd.getPath();
pwd.getAbsolutePath();
System.getProperty("user.dir");

Cheers,
Dian
[/code]
 
Thanks Dian,

pwd.getPath(); // prints: filename
pwd.getAbsolutePath(); // prints: /filename
System.getProperty("user.dir"); // prints: /

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
i wonder if the security is different on the Mac VM.
 
Yes, Dian. It's the same but with a .

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Perhaps the filename is coded as "File.txt".

Since windows doesn't really distinguish between upper- and lowercase in filenames, it will probably open a file called "file.txt", even if it shows up as "File.txt".

And I guess MacOs isn't that sloppy about filenames.

seeking a job as java-programmer in Berlin:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top