Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About help file's directory

 
Davidd Smith
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all,
I have a help menu when select will show a JEditorPane contains the userguide. I have the relative directory of the userguide in my programe.
But when I run the jar file from other directory other than the directory contains the relative directory, the system could not found it. How could I do to deal with it wherever I run the application?
Recards
Davidd
[ September 28, 2003: Message edited by: Davidd Smith ]
 
James Hook
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a routine that iterated through all the classpaths. If the classpath was a .jar file, then I had to use a JAR url to retrieve the helpfile from the JAR file.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to take a look at ClassLoader.getSystemResource(). It also may be worthwhile to put a copy of your documentation in runme.jar, to guarantee it will be accessible. In my instructions at least, the appication might be started from any directory, and we can't make any assumptions about the prexisting classpath. But we do know that the application is started with
java -jar runme.jar [mode]
So we know that runme.jar is in the classpath, even if nothing else is.
 
Davidd Smith
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Jim and James,
Thank you for your reply, I see
Regards
Davidd
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jim:
You might want to take a look at ClassLoader.getSystemResource().

Nice ! I didn't know that method. I wrote a getExecutionPathOf(Class aClass) method which could be simplified with ClassLoader.getSystemResource() IMO :

Anyway Davidd, passing any of your classes (the main one is a good candidate) to such a method will return the absolute path where your runme.jar is.
Best,
Phil.
[ September 30, 2003: Message edited by: Philippe Maquet ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic