homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Using JAR file in JavaScript
How to?

 11:52 am on Mar 27, 2003 (gmt 0)

I am trying to use jar files in javascript like
<SCRIPT language="javascript" archive="test.jar" src="foo.js"></SCRIPT>
<INPUT type="button" name="Click Me" value="Click Me" onClick="f1()">

foo.js contains
function f1() {

Both the html file and the jar file is in the same path.

When I run the html and click on the button it's not showing me the alert. Its showing error "Object Expected".
It is also not cacheing the jar file.

Can anyone help me.



 12:11 pm on Mar 27, 2003 (gmt 0)

do SCRIPT element support archive="test.jar"?


 2:15 pm on Mar 27, 2003 (gmt 0)

AFAIK you can only use .js files in the external link to javascripts.

Remember, JAVA uses .jar files and JAVASCRIPT (two different languages) uses .js files.

If you were using JSP pages, you might be able to use .jar files since those encapsulate stand alone classes.


 2:40 pm on Mar 27, 2003 (gmt 0)

In NN4 and IE4 (not sure about newer/older versions) the src attribute of the <Script> tag is complemented by the Archive attribute.

ARCHIVE specifies a JAR (java archive) file that contains a number of compressed JavaScript files (+other auxiliary files e.g. signature file).

If the webpage uses a number of JavaScript files it could be more efficient to combine them into a single compressed JAR file that can be loaded over the network. The ARCHIVE attribute details the name of the single .js file that you want to use within it, as in

<SCRIPT language="javascript" archive="lots-of-files.jar" src=" just1of- lots-of-files.js"></SCRIPT>

Trisonics, maybe the JAR isn't in the right format. I think Netscape provide a tool to create JAR files, that may be of use.


 5:34 pm on Mar 27, 2003 (gmt 0)

in m$ inet sdk
archive Property only avail for OBJECT

HocusPocus: can u give me url on NN4 and IE4 about archive for 'src'?


 5:50 pm on Mar 27, 2003 (gmt 0)

HocusPocus gave us the information from O'Reilly's "Javascript, The Definitive Guide" 3rd edition. But there is no mention of either the archive attribute or .jar files in the 4th edition.

We discussed this a long time ago in a thread about preloading js for the next page [webmasterworld.com], but no one seems to have any hands-on with it. Given its disappearance from O'Reilly, I'm infering that browser support has vanished. Trisonics' experience seems to confirm that, because the code looks right, according to the old reference.


 4:12 am on Mar 28, 2003 (gmt 0)

HocusPocus, I have tried Netscape tool "signtool" also.

So good information is also given in "http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/rsa_signing.html"

I have tried with both signed and unsigned jar.


 8:38 am on Mar 28, 2003 (gmt 0)


Had a go with the signtool also. Used the Netscape Developer one. (signtool13WIN95.zip)

Seems a little cumbersome using JARs, especially the process of signing them and tagging each Javascript event. Would be a bit of a pain maintaining it.

Could get NN 4.7 to read the contents of the Jar but no luck with IE 6 or Moz or NN 6+. Remembered the issue with IE and Applets so also tried CAB and Zip formats for curiosity's sake and completeness, same error "Object Expected".

Tried to help but not further forward. I think tedster and Xuefer are very much correct in saying that it is depreciated.

If your main aim was to reduce latency there's a good "javascript crunchinator" tool that crunches scripts to their bare bones. Donít miss off those semicolons though.



 9:19 am on Apr 2, 2003 (gmt 0)

I tried unsuccessfully.
Can you give the steps? It should be easier with unsigned JAR.


 9:49 am on Apr 2, 2003 (gmt 0)

my question is: how do u guys make use of it
as u say, only ** v4 support it
most of the users use ie 5.0+ & netscape 4.x or netscape 6.x+


 1:44 pm on Apr 2, 2003 (gmt 0)

For test purposes-

before you generate a key give yourself a password, by going to the navigator security info window.

Once done, open a command prompt.
Change dir to where the signtool.exe is

signtool -G [your_name] -d [your_path_to_netscape]

follow on screen instructions...should say at the end
certificate [your_name] added to database

Now sign your code, but make sure you id the functions in your html eg
<body onload="showAlert()" ID="s1">

Now do something like
signtool -J -k [your_name] [directory_of_files_to_sign]

I did say it was a little cumbersome.

Good Luck


 11:06 am on Apr 3, 2003 (gmt 0)

Thanx it worked. Netscape it's working fine.
IE its not working but its not giving any errors. I tried importing the certificate also. But no luck.

Will changing some configuration option help? Any ideas.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved