0

No I don't mean relative to project or working directory. I mean that the following command java -jar myJar.jar ~/ should provide a string with "/home/user"... This doesnt seem to be working as expected. I am passing the argument in via eclipse's "Run Configurations" menu and am not sure if this is causing a problem. The same result comes from a Runnable Jar... Its throwing a malformed URL exception... but URI doesnt like it either

Does anybody know a way to implement this functionality? Such that an argument ~/ is passed into (String[] args) as "/home/user"?

Jim Lewis
  • 43,505
  • 7
  • 82
  • 96

1 Answers1

0

It's not so much a Java issue as a shell issue.

The "tilde expansion" that replaces ~/ with /home/user/ is performed by the shell (on Unix-like operating systems). It looks like Eclipse doesn't do that expansion when using the "Run Configurations" menu, so you'll either have to specify /home/user/ directly, or write some Java code to detect a leading ~ in a pathname argument and perform the expansion yourself.

Jim Lewis
  • 43,505
  • 7
  • 82
  • 96