Pergunta

I am using Java in my FireFox extensions and I am unable since Mozilla stopped supporting Java in FireFox 16,17,18 . So I found that using LiveConnect it was possible before but now it's not.

Is there a way around that? I want to use Java in my FF extensions in versions 16 and above since people don't want to downgrade to version 15 that easily.

So far I had used java like this.

function createFile(folder,file)
{

destinationDir = new java.io.File(folder).mkdirs();
file = new java.io.File(folder,file);
file.createNewFile();
}

And it worked great. But this no longer works in FF I mentioned.

I found this question here.

Unable to load Java into Firefox 16 extension using Liveconnect

But no one replied.

Please don't lower my reputation because of this I work hard for it. If question is not properly asked then just close it. Thanks.

Foi útil?

Solução

This is an example of function I use to replace Java for my work.

var string = '\u5909\u63db\u30c6\u30b9\u30c8';
file.initWithPath('C:\\temp\\temp.txt');
file.create(file.NORMAL_FILE_TYPE, 0666);
var charset = 'EUC-JP';
var fileStream = Components
.classes['@mozilla.org/network/file-output-stream;1']
.createInstance(Components.interfaces.nsIFileOutputStream);
fileStream.init(file, 2, 0x200, false);
var converterStream = Components
.classes['@mozilla.org/intl/converter-output-stream;1']
.createInstance(Components.interfaces.nsIConverterOutputStream);
converterStream.init(fileStream, charset, string.length,
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
converterStream.writeString(string);
converterStream.close();
fileStream.close();

On mozilla developer documentation you can find more about this XPCOM that can be used for reading/writing files and similar procedures. So instead of Java I use this.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top