aspose file tools*
The moose likes Java in General and the fly likes migrate program from unix to windows, confuse about Path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "migrate program from unix to windows, confuse about Path" Watch "migrate program from unix to windows, confuse about Path" New topic
Author

migrate program from unix to windows, confuse about Path

Haulyn Jason
Ranch Hand

Joined: Jul 24, 2007
Posts: 37
Hi,all:
I have a java application which works well under linux. the folder structure of my application is like below:
app---lib
--lorenzo.jar
--work
--tmp
--data

I use this method to get the path of the lib folder:

it works well under my linux workstation, but when I migrate to windows xp with sp2, this code return the path of my $JAVA_HOME/bin path as "/d:/dev/java/jdk1.5.0/bin/"

I tried to change the code to :


It does not work, always return the jdk's bin path.

Is the jvm or classloader different from linux on windows? And how can I get the right path on windows?

Thanks!

ps: I invode my application by ant, and the main class of my application is extends Task class from ant.


Mama always said, "Life is like a box of chocolates; you never know what you're gonna get. And then you have to get medieval on somebody's buttocks."
http://www.haulynjason.net/
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19723
    
  20

Don't use the ClassLoader's resources, but the Class' resources.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Haulyn Jason
Ranch Hand

Joined: Jul 24, 2007
Posts: 37
I tried the following code:

But it does not work.

Should anybody tell me something about the difference of the two different platform: windows and Unix for java?

Thanks.
Haulyn Jason
Ranch Hand

Joined: Jul 24, 2007
Posts: 37
Some people told that the following code is better to use for crossing platform program, but it does not work.


Thanks.
Satya Maheshwari
Ranch Hand

Joined: Jan 01, 2007
Posts: 368
Will system.getProperty("user.dir") be of help?


Thanks and Regards
Haulyn Jason
Ranch Hand

Joined: Jul 24, 2007
Posts: 37
Hi, thank, Maheshwari. That's not my need.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

What version of the JDK are you using? I think what Rob suggested should work although I'd read up on the javadoc for using getResource(), I think you actually want getResource("/lib") or just getResource("lib")


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: migrate program from unix to windows, confuse about Path