2

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.

Community
  • 1
  • 1
edinvnode
  • 3,497
  • 7
  • 30
  • 53
  • 3
    "Please don't lower my reputation because of this I work hard for it." if your question gets downvoted, you can always delete it yourself (which should give you your reputation back) and repost it after you improve it. It's certainly more likely to work than pleading. – millimoose Jan 16 '13 at 17:53
  • 1
    Also, the general feel I get from searches seems to be "plugins are terrible, you shouldn't use them, least of all in extensions". (Though I might be projecting a bit there.) A rather ugly workaround seems to be this: http://pcscholl.de/2007/08/23/java-applets-in-xul/ – millimoose Jan 16 '13 at 18:03
  • I know all of these about java and FF but java is really useful in my works since many time saving operations depend on java. If I have to write something that can enable use of Java in FF16+ I will do it. I will work for solution if there is any. But I need guidance. – edinvnode Jan 16 '13 at 18:06
  • Well, I gave you one link to investigate, hope that helps. What do you mean by "time saving operations"? Javascript doesn't really perform too badly these days, unless your extension does an unusual lot of CPU processing I'm not sure it's worth the fuss using the JVM as an optimisation. – millimoose Jan 16 '13 at 18:13
  • 1
    @millimoose: Judging by the example, it has more to do with what operations are being done than performance. You can't create/enumerate files on the local file system from JavaScript, for example. – mellamokb Jan 16 '13 at 18:28
  • Can you create a web application instead, for example, a Java application hosted on Apache/Tomcat with the same functionality? – mellamokb Jan 16 '13 at 18:28
  • @mellamokb Bingo! JS has some limitations so Java came in really handy. Also loading csv,txt,doc files into script was few seconds long using Java. And JS also can't do that. So that is THE MAIN reason why I want to go around and make some classes or what ever that will enable me use of java in FireFox 16+. I am not familiar with creating a Web application for this purpose. However does it have to use Apache/Tomcat? I have nothing against that but people who ask for my services avoid additional installation. Still this could help me. Tutorials? P.S.I use iMacros addon for FF just so u know. – edinvnode Jan 16 '13 at 18:29
  • @mellamokb You can't create/enumerate them, but you can read ones the user picks out in an `` which can cover some of the use cases, combined with handing off to a service for processing. – millimoose Jan 16 '13 at 18:48
  • 1
    @IceD I think the idea was that instead of doing involved processing in the extension code, you build a web service using Java (or whatever you wish) that will do the heavy lifting for you. The service can be deployed on the client's servers or some webhosting of your own. (Of course this incurs ongoing costs.) While a Javascript extension has only limited communication with the local machine, it's free to communicate with the web as it wishes. It does complicate the architecture, but there's a reason why browser code is sandboxed, and this is the preferred way of getting out of the sandbox. – millimoose Jan 16 '13 at 18:51
  • 1
    @IceD: At this point why are you even using a web browser? Just build a full-blown Java application (or stand-alone Applet), and give them a link to download and run on their own machine. – mellamokb Jan 16 '13 at 18:56
  • So now I have to find some tut about how to build web app. :) Ok thanks. What else should i know? – edinvnode Jan 16 '13 at 18:57
  • Hi, I found some cross platform to use for this purpose. Can you look up the question here. http://stackoverflow.com/questions/14490710/javascript-write-file-without-overwrite – edinvnode Jan 23 '13 at 22:40
  • 1
    Cannot you simply download and reinstall the latest Java release? FireFox periodically disables old, outdated Java versions with known security bugs - why to stick with them when there there are new, fixed new versions. It is not disabling Java permanently. – Audrius Meškauskas Jan 28 '13 at 07:33
  • The same problem happened in FF16,17,18 and I read on their official forum that they stopped the support of java in total. I found a solution for this using XPCOM to make functions that will do the job. – edinvnode Jan 28 '13 at 14:07
  • 1
    @IceD - if you are going to quote what you read elsewhere, please provide links or references. There is not enough info in this question. – djangofan Jan 30 '13 at 00:43

1 Answers1

0

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.

edinvnode
  • 3,497
  • 7
  • 30
  • 53