Question

I can't figure out how to use jslib in a xul standalone application.

in the chrome.manifest I added:

content jslib jar:chrome/content/jslib.jar!/ 

in my xul file I have:

<script type="application/javascript" src="chrome://jslib/io/fileUtils.js" />

Downloaded the jslib from https://www.mozdevgroup.com/dropbox/jslib/jslib_current.xpi and opened it in archive manager, then extracted the chrome/jslib.jar and copied it to chrome/content

When I start my application I get the error:

No chrome package registered for chrome://jslib/io/fileUtils.js

[update]

Note that I am not running my app with xulrunner but with firefox --app so not sure where to copy the files according to this information.

[update]

Severely frustrated: MZ examples use jslib a lot but NOWHERE do they explain how to get it to work in your application. It is a shared library and should be installed once instead of delivered with your application but I've already installed the jslib extension in firefox yet running xul apps with firefox --app does not use the extensions installed in firefox so I have to deliver the libraries with my app somehow. I like the idea of creating xul apps but as long as it's not documented AT ALL then it's painfully hard to do anything with it.

Even after extracting the jslib and putting it in my content directory it doesn't work. Including the fileUtils with

<script type="application/javascript" 
  src="chrome://myapp/content/jslib/io/fileUtils.js">
</script>

In my xul file gives me a whole bunch of warnings about fileUtils.js but still typeof jslib is undefined.

Was it helpful?

Solution

If I run my application with firefox --app the first time it seems a new profile is created. I got the location of this profile with:

var file = Components.classes["@mozilla.org/file/directory_service;1"].
           getService(Components.interfaces.nsIProperties).
           get("ProfD", Components.interfaces.nsIFile);

alert(file.path);

Then I went to my firefox profile /home/me/.mozilla/firefox/82xw54jj.default/ and copied the extensions directory in the profile directory of my application. Now I can use jslib like so:

Components.utils.import("resource://gre/modules/FileUtils.jsm");
file = new FileUtils.File("/home");
alert(file);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top