Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Little question on accessing files in a jar

 
Juan Ec
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good night colleagues
a stupid question, but i have made searches in old posts and could not find response.
i'd like to have in my executable jar (both for client and server) the html files for the online help my application uses, but i can't make this work, the system is not able to find the help/index.html file unless i put outside the jar.
any advise please?
thank you very much
[ November 02, 2002: Message edited by: Jaun Katabasis ]
 
Juan Ec
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've resolved the problem
thanks anyway
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaun,
could you please let me know how you solved the problem?
Thank you!
 
Juan Ec
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
my jar test file has 'help' and 'suncertify' (and META-INF) as directories.
helpURL = ClassLoader.getSystemResource (HELP_FILE_NAME)
where HELP_FILE_NAME is defined in ClientConstantsI and values "help/hlp.html" works ok
but for some reason, if i provide to getSystemResource an argument something like
HELP_FILE_DIR + System.getProperty("file.separator") + HELP_FILE_NAME
( this is, "help\\hlp.html" )
it will work ok if executed in uncompressed directories but not inside the jar. that was my initial problem.
i don�t like the solution, as hardcoding "/" as file separator goes against portability, but i can�t find a better solution.
[ November 04, 2002: Message edited by: Jaun Katabasis ]
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaun,
thank you for the hint! I'll try it.
Regarding the slash "/", try this:

I usually assign the return value to a constant in an interface, which contains all sorts of constants and is available to the application as a whole.
Hope this helps.
[ November 04, 2002: Message edited by: Mag Hoehme ]
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaun,
I found out how to view HTML files packed into a jar file. check out my exemplary JarBrowser at
http://www.mhoehme.de/java/jarbrowser/index.html.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic