• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem With JAR

 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I had created a client.jar file. When I place this in other directory or in root directory. java.io.FileNotFoundException is the error which I get. The thing is this error comes due to non availability of my help.html file in path. My question is how should I write jar's manifest file such, that it can load my html file during run-time ?.
The code currently I am using Is:
documentURL = "file:" + System.getProperty("user.dir") + System.getProperty
("file.separator") + htmlDocument;
URL helpURL = new URL(documentURL);
editor.setPage(documentURL);

The problem which I realize is "user.dir" fetches the current working directory. Whereas, my help.html file is embedded in jar file. This is truly a problem between a specified directory location whereas, above code is hard code that is it assumes that main.jar is once extracted and then it will simply point the files.
Thank yu.
Gurpreet
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should put the html and image file(s) into your jar file along with your .class files and create an URL using code like this:

You can also look for the files on the filesystem as well (which is what I did so help would work when I was running straight from disk), but it's not necessary as long as you put the help files in your jar as well as on the filesystem so the assesor can view them in a browser.
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi lyons,
I tried with your code but it gives me IOException: Invalid URL. After, that I tried to print helpURL object and to my surprise it shows me null. So, IOException has to come. I embedded my ClientHelp.html file in root of jar that is I did not put my file anywhere in directory. If possible then please elaborate it.
Thank you,
Gurpreet
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic