Re: Problem with java
Josué Leal Moura Dantas <[email protected]> Wed, 23 Mar 2011 17:32:40 -0300
| Newsgroups | gmane.comp.mozilla.devel.java |
|---|---|
| Message-ID | <[email protected]> |
I use a similar code, but as you said in jars I made a change and now I can still run the extension by first time, but the second the following error appears in the console "Erro: java.net.URL is not a constructor". 2011/3/23 Markus Doering <[email protected]> > Maybe this will help: > loadXpcom : function() { > //Path des LiveConnect Moduls HINT: don't forget to register > Livconnect modul in manifest > Components.utils['import']('resource://verConSign/LiveConnectUtils.js', > this.LiveConnect); > var jars =3D ['URLSetPolicy.jar', 'Test.jar']; > var [loader,urls] =3D this.LiveConnect.initWithPrivs(java, > '[email protected]', jars); > myClass =3D loader.loadClass('Test'); > var myObj =3D myClass.newInstance(); > if (myObj =3D=3D null) { > } else { > var binval =3D myObj.hello('Hello World test!'); > alert(binval); > } > return myObj; > }, > > 2011/3/23 Josu=E9 Leal Moura Dantas <[email protected]> > > > > I had already included all the jars that the class uses, but have I > instantiate the classes too? Even that I had alrealdy included the jars > where they are? > > > > 2011/3/23 Markus Doering <[email protected]> > >> > >> I created one JAR from my java project which i included in JavaScript. > >> I was using other APIs in this java project with external Jars (like > log4j). But this didn't work. I had to include all sourcefiles directly in > my java project. Otherwise i got an Exception from the error console of > Firefox. > >> I used this tutorial: > >> https://developer.mozilla.org/en/java_in_firefox_extensions > >> > >> 2011/3/23 Josu=E9 Leal Moura Dantas <[email protected]> > >>> > >>> Yes, my code is using other jars, but have I to include them in > javascript code? > >>> > >>> 2011/3/23 Markus Doering <[email protected]> > >>>> > >>>> Do you use other projets-jars in your BuildPath? This wont work! You > have to include this Sourcefiles directly into your package! > >>>> > >>>> 2011/3/23 Josu=E9 Leal Moura Dantas <[email protected]> > >>>>> > >>>>> I've done thsis, but the strange thing is that the first call the > function works, but in the second time a mentioned error happens, I think > it's because in my method instantiate many objects of other classes, any > other suggestions? > >>>>> > >>>>> 2011/3/22 Markus Doering <[email protected]> > >>>>>> > >>>>>> Hi there, > >>>>>> make a try-catch throug your code example. And catch this Exception > with like this: > >>>>>> Class Test { > >>>>>> public static void myMethod (String test) { > >>>>>> try { > >>>>>> ...my Code > >>>>>> } catch (Exception e) { > >>>>>> e.printStackTrace > >>>>>> } > >>>>>> Use always the Generic Exception. > >>>>>> Enable Browser-Plugin console and you get a correct Exception. You > must do try and error! > >>>>>> Good Luck! > >>>>>> 2011/3/22 Josu=E9 Leal Moura Dantas <[email protected]> > >>>>>>> > >>>>>>> I'm making an extension that calls a method of a java class in a > jar through > >>>>>>> of the Liveconnect. I got to make the call, but it only do the > first time, the > >>>>>>> second the following error is displayed "Error: uncaught exceptio= n: > >>>>>>> java.lang.reflect.InvocationTargetException", can anyone help me? > >>>>>>> > >>>>>>> -- > >>>>>>> Josu=E9 Leal Moura Dantas > >>>>>>> _______________________________________________ > >>>>>>> dev-tech-java mailing list > >>>>>>> [email protected] > >>>>>>> https://lists.mozilla.org/listinfo/dev-tech-java > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> -- > >>>>> Josu=E9 Leal Moura Dantas > >>>>> Mestrando em Ci=EAncia da Computa=E7=E3o (UFPA) > >>>>> (94) 8117-0893 > >>>> > >>> > >>> > >>> > >>> -- > >>> Josu=E9 Leal Moura Dantas > >>> Mestrando em Ci=EAncia da Computa=E7=E3o (UFPA) > >>> (94) 8117-0893 > >> > > > > > > > > -- > > Josu=E9 Leal Moura Dantas > > Mestrando em Ci=EAncia da Computa=E7=E3o (UFPA) > > (94) 8117-0893 > -- = Josu=E9 Leal Moura Dantas Mestrando em Ci=EAncia da Computa=E7=E3o (UFPA) (94) 8117-0893