Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

migrate program from unix to windows, confuse about Path

 
Haulyn Jason
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20529
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use the ClassLoader's resources, but the Class' resources.
 
Haulyn Jason
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will system.getProperty("user.dir") be of help?
 
Haulyn Jason
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thank, Maheshwari. That's not my need.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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")
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic