• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Local HTTP file question

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the following code on the web:



I compiled it and it runs just fine.

My next steps are to:

1) put all 4 of the class files and about 4,000 HTML files into a JAR file. I tried to run jar -cf jarName.jar *.class to import the class files into my Jar, but it didn't work. I was able to get the class files into the Jar, but I guess it's having problems finding the "executoable" public static void main(String [] args)...


2) I want to use this code to launch index.html which will be inside of the Jar file.

3) from index.html, allow the user to navigate from one page in the JAR file to the next.

How can I do this?

Currently the line



is not accepting index.html as the default html file name.

What do I have to point Browser() at?
[ January 26, 2005: Message edited by: Marcus Laubli ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Browser constructor does not take a file name as an argument. It takes a URL.
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1) I tried to run jar -cf jarName.jar *.class to import the class files into my Jar, but it didn't work.



use jar -cfm option to create jar file specifying all class files and create a manifest file.

having problems finding the "executoable" public static void main(String [] args)...



edit Manifest file to add another line

Main-Class: classname

the class which has main(..) method.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To get a URL to a file within a JAR file, you can use ClassLoader.getSystemResource().

Layne
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic