• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

online user guide

 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the specification it says that I can have the user guid online (accessable withing the application). How can I do that without requiring the userguide.txt to be available in the current working directory?

I must not require any addintiona files to run the program, hence I cannot have a user guide text file so the application can read from it.

The only way I see it is to hardcode the user guide as a String parameter in a class, which of course IMO very very poor design.

any suggestions?
Note: I tried to packaged the user guide text file with the runme.jar, but it doesn't see it.
 
HaoZhe Xu
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are allowed to have an extra txt file in your working directory, or other directory.
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Note: I tried to packaged the user guide text file with the runme.jar, but it doesn't see it.


Please elaborate.
Where is the text file? in or out of executable jar?
What code do you use to 'see it'?
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HaoZhe :
I think you are allowed to have an extra txt file in your working directory, or other directory

No, you are not allwod unless it is specified in you spec.

Mike:
I tried to put inside the excecutable jar, but when you run the jar file, it doesn't see it. The first place to look to is the working directory.
What code do you use to 'see it'?

I use a RandomAccessFile to read it, then set it in a JTextArea, so the user can look at it.
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I tried to put inside the excecutable jar, but when you run the jar file, it doesn't see it. The first place to look to is the working directory.

I use a RandomAccessFile to read it, then set it in a JTextArea, so the user can look at it.



As I thought.

There is no concept of File within a Jar. A Jar is a file, it only has other files when unarchived, this does not happen during execution.

The way to get at files inside Jar is to use Class.getResourceAsStream(...)
This obviously isn't appropriate for RAF, so you must have your RAF outside your Jar.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

When using URIs, you can use the jar:// protocol specifier to state that the file is inside a jar file

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic