How to put javaScript code in Java program/application? - java

Trying to put in your application code of Ace Editor: http://ace.c9.io/#nav=embedding.
I found something like this: http://metoojava.wordpress.com/2010/06/20/execute-javascript-from-java/
and I put this code:
engine.eval(new java.io.FileReader("ace-builds/src-noconflict/ace.js"));
But I have build errors.
Exception in thread "main" javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined. (<Unknown source>#1513) in <Unknown source> at line number 1513
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:224)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
at javaapplication9.JavaApplication9.main(JavaApplication9.java:28)
Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined. (<Unknown source>#1513)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3770)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3748)
at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(ScriptRuntime.java:3833)
at sun.org.mozilla.javascript.internal.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1826)
at sun.org.mozilla.javascript.internal.ScriptRuntime.name(ScriptRuntime.java:1765)
at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1785)
at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:849)
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:162)
at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:430)
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116)
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109)
at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3160)
at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:173)
at sun.org.mozilla.javascript.internal.Context.evaluateReader(Context.java:1169)
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:214)
... 2 more
Do any of you know how can I do this?
Thans for help and Happy Holidays!

Keep in mind that you are executing a Javascript file out of context.
This Javascript file is usually executed with the browser JS engine so if you are not in that context you could not access to some objects like navigator, window... etc.

Related

GSP Exception thrown for "Method code too large"?

I am getting the exception below when I try to access my Grails application. What is the problem?
Error | 2019-10-10 16:24:39,538 [http-bio-8080-exec-10] ERROR
pages.GroovyPagesTemplateEngine - Compilation error compiling GSP
[C__praveen_HOTS_grails_app_views_main_monetarystatusdet_gsp]:startup
failed: General error during class generation: Method code too large!
java.lang.RuntimeException: Method code too large! at
groovyjarjarasm.asm.MethodWriter.a(Unknown Source) at
groovyjarjarasm.asm.ClassWriter.toByteArray(Unknown Source) at
org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:796)
at
org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:811)
at
org.codehaus.groovy.control.CompilationUnit$15.call(CompilationUnit.java:811)
at
The issue is that your GSP has too much code within it and exceeds the 65K (or so) lines per script block. The "workaround" is to add a comment in the GSP to break up the script block size like this:
<%
// just a comment
%>
Placing that somewhere in the middle or in several spots in your GSP file will resolve this issue.

Gen-Class does not generate a .class file

I'd like to use Clojure code within Java. The Clojure code itself should implement a Java-interface (TestGenClassInterface).
My project.clj is:
(defproject com.stackoverflow.clojure/tests "0.1.0-SNAPSHOT"
:description "Tests of Clojure test-framework."
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[instaparse "1.3.4"]]
:source-paths ["src/main/clojure"]
:java-source-paths ["src/main/java"]
:test-paths ["src/test/clojure"]
:java-test-paths ["src/test/java"]
;:aot :all
)
The Java interface looks like this:
package com.stackoverflow.clojure;
public interface TestGenClassInterface {
public String addToString(String text, String appendText);
}
The Clojure code is:
(ns com.stackoverflow.clojure.testGenClass
(:gen-class
:name com.stackoverflow.clojure.TestGenClass
:implements com.stackoverflow.clojure.TestGenClassInterface
:prefix "java-"))
(def ^:private pre "START: ")
(defn java-addToString [this text post]
(str pre text post))
(java-addToString "TexT" " :END")
I expected, that after running lein compile or "Run as Clojure-Application" in eclipse+CounterClockwise a .class file (named TestGenClass.class) is generated an saved within *compile-path* (here: target/classes/com/stackoverflow/clojure/). Unfortunately it's not.
When adding :aot :all to my project.clj, I get the following stacktrace:
Compiling com.stackoverflow.clojure.testGenClass
Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol, compiling:(com/stackoverflow/clojure/testGenClass.clj:1:1)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6651)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyze(Compiler.java:6406)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782)
at clojure.lang.Compiler$TryExpr$Parser.parse(Compiler.java:2191)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6644)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyze(Compiler.java:6406)
at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:5782)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5217)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3846)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6642)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6632)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyze(Compiler.java:6406)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3665)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6646)
at clojure.lang.Compiler.analyze(Compiler.java:6445)
at clojure.lang.Compiler.analyze(Compiler.java:6406)
at clojure.lang.Compiler.compile1(Compiler.java:7221)
at clojure.lang.Compiler.compile1(Compiler.java:7216)
at clojure.lang.Compiler.compile(Compiler.java:7292)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5066.invoke(core.clj:5641)
at clojure.core$load.doInvoke(core.clj:5640)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5446)
at clojure.core$compile$fn__5071.invoke(core.clj:5652)
at clojure.core$compile.invoke(core.clj:5651)
at user$eval9.invoke(form-init4595004281107083893.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6693)
at clojure.lang.Compiler.load(Compiler.java:7130)
at clojure.lang.Compiler.loadFile(Compiler.java:7086)
at clojure.main$load_script.invoke(main.clj:274)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invoke(main.clj:307)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:420)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
at clojure.lang.RT.seqFrom(RT.java:505)
at clojure.lang.RT.seq(RT.java:486)
at clojure.core$seq.invoke(core.clj:133)
at clojure.core$map$fn__4245.invoke(core.clj:2551)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:484)
at clojure.core$seq.invoke(core.clj:133)
at clojure.core$map$fn__4245.invoke(core.clj:2551)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.boundedLength(RT.java:1654)
at clojure.lang.RestFn.applyTo(RestFn.java:130)
at clojure.core$apply.invoke(core.clj:624)
at clojure.core$mapcat.doInvoke(core.clj:2586)
at clojure.lang.RestFn.invoke(RestFn.java:423)
at clojure.core$generate_class.invoke(genclass.clj:164)
at clojure.core$gen_class.doInvoke(genclass.clj:638)
at clojure.lang.RestFn.invoke(RestFn.java:1557)
at clojure.lang.Var.invoke(Var.java:519)
at clojure.lang.AFn.applyToHelper(AFn.java:270)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.lang.Compiler.macroexpand1(Compiler.java:6552)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6630)
... 46 more
Compilation failed: Subprocess failed
The proximate issue you have is a missing :aot :all in your project.clj file. Without that the ahead-of-time compilation will not be attempted.
Once you put that in, you'll have the following further issues:
you must prefix the names of the functions designated to become Java methods (default prefix is -);
you must include this as an explicit first argument of each such method (this is the recommended convention, but any name is acceptable);
you must correct your :implements clause: it takes a vector as the value, even if it has a single member.
According to http://clojure.org/compilation
... the implementation functions for instance methods will always take an
additional first arg corresponding to the object the method is called
upon, called by convention 'this' here.
Try adding 'this' to each function definition.
(defn java-addToString [this text post]
...
http://clojure.org/compilation mentions the compilation process makes use of
... *compile-path*, which must be in the classpath
The default location is a classes folder.
The second answer to Stack Overflow question Compiling Clojure? mentions that this path is relative to the jvm startup folder. If you did lein repl from the main project folder (the folder where project.clj lives) then creating a classes folder there should make it work.

org.openide.util.RequestProcessor$SlowItem exception in basic NetBeans plugin

I followed a tutorial to build a simple plugin for NetBeans v 7.3.1 ... I know this is an older version of NetBeans but I'm restricted by the software my employer insists on using.
All I have is a simple plugin that loads a toolbar item that consists of a button. But when I run the plugin, I always get the same exception alert in a popup:
A org.openide.util.RequestProcessor$SlowItem exception has occurred.
Please report this at [blah blah website blah blah log file created]
This message hasn't been helpful solving the problem. Here is the log file, which as a Java n00b I've been unable to decipher or understand what is going on in it well enough to figure out why I'm getting this error. And there's little to no info I've been able to find in searches. If I'm reading it right (I'm sure I'm not reading it right) then the error is happening in .jar files where I can't do anything about it. So is there anything I can hope to do to ship a plugin that will run without throwing exceptions? Workaround? Something stupid I missed as a n00b?
SEVERE [org.openide.util.RequestProcessor]: Error in RequestProcessor org.openide.loaders.FolderInstance$1R
java.lang.NullPointerException
at org.openide.util.Exceptions$AnnException.getMessage(Exceptions.java:238)
at org.openide.util.Exceptions$AnnException.toString(Exceptions.java:321)
at java.util.Objects.toString(Objects.java:159)
at java.lang.Throwable.initCause(Throwable.java:457)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:279)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:286)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:286)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:286)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:286)
at org.openide.util.Exceptions$AnnException.findOrCreate(Exceptions.java:256)
at org.openide.util.Exceptions.attachMessage(Exceptions.java:85)
at org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:157)
at org.openide.loaders.InstanceDataObject$Ser.instanceClass(InstanceDataObject.java:1338)
at org.openide.loaders.InstanceDataObject.instanceClass(InstanceDataObject.java:809)
at org.openide.awt.MenuBar$LazyMenu$MenuFolder.acceptCookie(MenuBar.java:808)
at org.openide.loaders.FolderInstance.acceptDataObject(FolderInstance.java:419)
at org.openide.loaders.FolderInstance.defaultProcessObjects(FolderInstance.java:795)
at org.openide.loaders.FolderInstance.access$000(FolderInstance.java:103)
at org.openide.loaders.FolderInstance$1R.init(FolderInstance.java:693)
at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:720)
Caused: org.openide.util.RequestProcessor$SlowItem: task failed due to
at org.openide.util.RequestProcessor$Task.schedule(RequestProcessor.java:1473)
at org.openide.loaders.FolderInstance.processObjects(FolderInstance.java:768)
at org.openide.loaders.FolderInstance$Listener.finished(FolderInstance.java:1052)
at org.openide.loaders.FolderList.createBoth(FolderList.java:923)
at org.openide.loaders.FolderList.getObjects(FolderList.java:608)
at org.openide.loaders.FolderList.access$200(FolderList.java:77)
at org.openide.loaders.FolderList$ListTask.computeResult(FolderList.java:1007)
at org.openide.loaders.FolderList$ListTask.run(FolderList.java:983)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044)
WARNING [org.netbeans.ProxyClassLoader]: Will not load class org.netbeans.modules.editor.NbCodeFoldingAction arbitrarily from one of ModuleCL#183d64f7[org.netbeans.modules.editor] and ModuleCL#52954826[com.mycompany.TrestleLauncher] starting from SystemClassLoader[263 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE
INFO [org.openide.loaders.FolderInstance.Menu.View]
Cannot get class for MultiFileObject#26bf742[Menu/View/org-netbeans-modules-editor-NbCodeFoldingAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
Cannot get class for MultiFileObject#26bf742[Menu/View/org-netbeans-modules-editor-NbCodeFoldingAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
Caused: java.lang.NullPointerException
at org.openide.util.Exceptions$AnnException.getMessage(Exceptions.java:238)
at org.openide.util.Exceptions$AnnException.toString(Exceptions.java:321)
at java.util.Objects.toString(Objects.java:159)
at java.lang.Throwable.initCause(Throwable.java:457)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:279)
at org.openide.util.Exceptions$AnnException.findOrCreate(Exceptions.java:256)
at org.openide.util.Exceptions.attachMessage(Exceptions.java:85)
at org.openide.loaders.InstanceSupport.findClass(InstanceSupport.java:506)
at org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:148)
Caused: java.lang.ClassNotFoundException: From file: MultiFileObject#26bf742[Menu/View/org-netbeans-modules-editor-NbCodeFoldingAction.instance] due to
at org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:162)
at org.openide.loaders.InstanceDataObject$Ser.instanceClass(InstanceDataObject.java:1338)
at org.openide.loaders.InstanceDataObject.instanceClass(InstanceDataObject.java:809)
at org.openide.awt.MenuBar$LazyMenu$MenuFolder.acceptCookie(MenuBar.java:808)
[catch] at org.openide.loaders.FolderInstance.acceptDataObject(FolderInstance.java:419)
at org.openide.loaders.FolderInstance.defaultProcessObjects(FolderInstance.java:795)
at org.openide.loaders.FolderInstance.access$000(FolderInstance.java:103)
at org.openide.loaders.FolderInstance$1R.init(FolderInstance.java:693)
at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:720)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044)
ALL [null]: Cannot get class for MultiFileObject#26bf742[Menu/View/org-netbeans-modules-editor-NbCodeFoldingAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
WARNING [org.netbeans.modules.editor.settings.storage.keybindings.KeyMapsStorage]: The keybinding 'A-MOUSE_WHEEL_UP' in Editors/Keybindings/NetBeans/Defaults/org-netbeans-modules-editor-keybindings.xml may not work correctly on Mac. Keybindings starting with Alt or Ctrl should be coded with latin capital letters 'O' or 'D' respectively. For details see org.openide.util.Utilities.stringToKey().
WARNING [org.netbeans.modules.editor.settings.storage.keybindings.KeyMapsStorage]: The keybinding 'A-MOUSE_WHEEL_DOWN' in Editors/Keybindings/NetBeans/Defaults/org-netbeans-modules-editor-keybindings.xml may not work correctly on Mac. Keybindings starting with Alt or Ctrl should be coded with latin capital letters 'O' or 'D' respectively. For details see org.openide.util.Utilities.stringToKey().
WARNING [org.netbeans.ProxyClassLoader]: Will not load class org.netbeans.modules.editor.MainMenuAction$GoToSourceAction arbitrarily from one of ModuleCL#183d64f7[org.netbeans.modules.editor] and ModuleCL#52954826[com.mycompany.TrestleLauncher] starting from SystemClassLoader[263 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE
INFO [org.openide.loaders.FolderInstance.Menu.GoTo]
Cannot get class for MultiFileObject#7e5308ff[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSourceAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
Cannot get class for MultiFileObject#7e5308ff[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSourceAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
Caused: java.lang.NullPointerException
at org.openide.util.Exceptions$AnnException.getMessage(Exceptions.java:238)
at org.openide.util.Exceptions$AnnException.toString(Exceptions.java:321)
at java.util.Objects.toString(Objects.java:159)
at java.lang.Throwable.initCause(Throwable.java:457)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:279)
at org.openide.util.Exceptions$AnnException.findOrCreate(Exceptions.java:256)
at org.openide.util.Exceptions.attachMessage(Exceptions.java:85)
at org.openide.loaders.InstanceSupport.findClass(InstanceSupport.java:506)
at org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:148)
Caused: java.lang.ClassNotFoundException: From file: MultiFileObject#7e5308ff[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSourceAction.instance] due to
at org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:162)
at org.openide.loaders.InstanceDataObject$Ser.instanceClass(InstanceDataObject.java:1338)
at org.openide.loaders.InstanceDataObject.instanceClass(InstanceDataObject.java:809)
at org.openide.awt.MenuBar$LazyMenu$MenuFolder.acceptCookie(MenuBar.java:808)
[catch] at org.openide.loaders.FolderInstance.acceptDataObject(FolderInstance.java:419)
at org.openide.loaders.FolderInstance.defaultProcessObjects(FolderInstance.java:795)
at org.openide.loaders.FolderInstance.access$000(FolderInstance.java:103)
at org.openide.loaders.FolderInstance$1R.init(FolderInstance.java:693)
at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:720)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044)
ALL [null]: Cannot get class for MultiFileObject#7e5308ff[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSourceAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
WARNING [org.netbeans.ProxyClassLoader]: Will not load class org.netbeans.modules.editor.MainMenuAction$GoToSuperAction arbitrarily from one of ModuleCL#183d64f7[org.netbeans.modules.editor] and ModuleCL#52954826[com.mycompany.TrestleLauncher] starting from SystemClassLoader[263 modules]; see http://wiki.netbeans.org/DevFaqModuleCCE
INFO [org.openide.loaders.FolderInstance.Menu.GoTo]
Cannot get class for MultiFileObject#210198eb[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSuperAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
Cannot get class for MultiFileObject#210198eb[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSuperAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
Caused: java.lang.NullPointerException
at org.openide.util.Exceptions$AnnException.getMessage(Exceptions.java:238)
at org.openide.util.Exceptions$AnnException.toString(Exceptions.java:321)
at java.util.Objects.toString(Objects.java:159)
at java.lang.Throwable.initCause(Throwable.java:457)
at org.openide.util.Exceptions$AnnException.findOrCreate0(Exceptions.java:279)
at org.openide.util.Exceptions$AnnException.findOrCreate(Exceptions.java:256)
at org.openide.util.Exceptions.attachMessage(Exceptions.java:85)
at org.openide.loaders.InstanceSupport.findClass(InstanceSupport.java:506)
at org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:148)
Caused: java.lang.ClassNotFoundException: From file: MultiFileObject#210198eb[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSuperAction.instance] due to
at org.openide.loaders.InstanceSupport.instanceClass(InstanceSupport.java:162)
at org.openide.loaders.InstanceDataObject$Ser.instanceClass(InstanceDataObject.java:1338)
at org.openide.loaders.InstanceDataObject.instanceClass(InstanceDataObject.java:809)
at org.openide.awt.MenuBar$LazyMenu$MenuFolder.acceptCookie(MenuBar.java:808)
[catch] at org.openide.loaders.FolderInstance.acceptDataObject(FolderInstance.java:419)
at org.openide.loaders.FolderInstance.defaultProcessObjects(FolderInstance.java:795)
at org.openide.loaders.FolderInstance.access$000(FolderInstance.java:103)
at org.openide.loaders.FolderInstance$1R.init(FolderInstance.java:693)
at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:720)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044)
ALL [null]: Cannot get class for MultiFileObject#210198eb[Menu/GoTo/org-netbeans-modules-editor-MainMenuAction$GoToSuperAction.instance] defined by [jar:file:/C:/Program%20Files/NetBeans%207.3.1/ide/modules/org-netbeans-modules-editor.jar!/org/netbeans/modules/editor/resources/layer.xml]
WARNING [org.openide.filesystems.Ordering]: Not all children in Menu/Window/ marked with the position attribute: [Other], but some are: [org-netbeans-modules-project-ui-logical-tab-action.shadow, org-netbeans-modules-project-ui-physical-tab-action.shadow, org-netbeans-modules-favorites-View.shadow, org-netbeans-core-ide-ServicesTabAction.shadow, org-netbeans-modules-tasklist-ui-TaskListAction.shadow, ShowPaletteAction.shadow, org-netbeans-core-windows-actions-GlobalPropertiesAction.shadow, Output, Navigator, Debug, Versioning, Web, SwitchToRecentDocumentAction.shadow, ProgressListAction.shadow, Separator3.instance, ConfigureWindow, org-netbeans-core-windows-actions-ResetWindowsAction.shadow, Separator4.instance, CloseWindowAction.shadow, CloseAllDocumentsAction.shadow, CloseAllButThisAction.shadow, DocumentsAction.shadow]
WARNING [org.netbeans.TopSecurityManager]: use of system property netbeans.user has been obsoleted in favor of InstalledFileLocator/Places at org.netbeans.modules.uihandler.Installer.logsDirectory(Installer.java:840)
INFO [org.netbeans.core.netigso.Netigso]: bundle org.eclipse.osgi#3.8.0.v20120529-1548 256
INFO [org.netbeans.core.netigso.Netigso]: bundle org.eclipse.osgi#3.8.0.v20120529-1548 stopped
INFO [org.netbeans.core.netigso.Netigso]: bundle org.eclipse.osgi#3.8.0.v20120529-1548 stopped
This seems to have been a result of adding a library package via Wrapped .JAR that didn't need to be added (or more accurately, needed to be added using a more correct method). Instead of finding, downloading, and depending on Wrapped .JAR files to account for dependencies, I needed to add module dependencies by name (not by package) in NetBeans.

Baksmali error for android odex file

I downloaded core.odex and framework.odex from my Samsung Galaxy Player, in order to make some changes for the hidden apis, following this webpage: https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-2-hacking-around/
Also, I got baksmali and smali from here: http://forum.xda-developers.com/showthread.php?t=1650243
Now, when I run the command: java -jar baksmali-1.3.3.jar -c :core.odex -x framework.odex, the following error appears:
UNEXPECTED TOP-LEVEL EXCEPTION:
org.jf.dexlib.Util.ExceptionWithContext: regCount does not match the number of arguments of the method
at org.jf.dexlib.Util.ExceptionWithContext.withContext(ExceptionWithContext.java:54)
at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(InstructionIterator.java:92)
at org.jf.dexlib.CodeItem.readItem(CodeItem.java:154)
at org.jf.dexlib.Item.readFrom(Item.java:76)
at org.jf.dexlib.OffsettedSection.readItems(OffsettedSection.java:48)
at org.jf.dexlib.Section.readFrom(Section.java:143)
at org.jf.dexlib.DexFile.<init>(DexFile.java:431)
at org.jf.baksmali.main.main(main.java:265)
Caused by: java.lang.RuntimeException: regCount does not match the number of arguments of the method
at org.jf.dexlib.Code.Format.Instruction3rc.checkItem(Instruction3rc.java:129)
at org.jf.dexlib.Code.Format.Instruction3rc.<init>(Instruction3rc.java:79)
at org.jf.dexlib.Code.Format.Instruction3rc.<init>(Instruction3rc.java:44)
at org.jf.dexlib.Code.Format.Instruction3rc$Factory.makeInstruction(Instruction3rc.java:145)
at org.jf.dexlib.Code.InstructionIterator.IterateInstructions(InstructionIterator.java:84)
... 6 more
Error occured at code address 0
code_item #0x159a90
What am I missing or doing wrong?
Appreciate in advance any help you can provide.

Cannot use document javascript object when running from Java

I have the following javascript code that runs from java:
var doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
doc.documentElement.innerHTML = xmlResponse;
And I get the following error:
Caused by: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "document" is not defined. (<Unknown source>#13)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3773)
at sun.org.mozilla.javascript.internal.ScriptRuntime.constructError(ScriptRuntime.java:3751)
at sun.org.mozilla.javascript.internal.ScriptRuntime.notFoundError(ScriptRuntime.java:3836)
at sun.org.mozilla.javascript.internal.ScriptRuntime.name(ScriptRuntime.java:1762)
at sun.org.mozilla.javascript.internal.Interpreter.interpretLoop(Interpreter.java:1790)
at sun.org.mozilla.javascript.internal.Interpreter.interpret(Interpreter.java:854)
at sun.org.mozilla.javascript.internal.InterpretedFunction.call(InterpretedFunction.java:164)
at sun.org.mozilla.javascript.internal.ContextFactory.doTopCall(ContextFactory.java:429)
at com.sun.script.javascript.RhinoScriptEngine$1.superDoTopCall(RhinoScriptEngine.java:116)
at com.sun.script.javascript.RhinoScriptEngine$1.doTopCall(RhinoScriptEngine.java:109)
at sun.org.mozilla.javascript.internal.ScriptRuntime.doTopCall(ScriptRuntime.java:3163)
at sun.org.mozilla.javascript.internal.InterpretedFunction.exec(InterpretedFunction.java:175)
at sun.org.mozilla.javascript.internal.Context.evaluateReader(Context.java:1159)
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:210)
... 16 more
Do you have any clue of how to solve it?
According to the documentation:
The window object represents an open window in a browser.
Since you are not executing your script in a browser, the window object is not defined.
You can read the URL using the URL/URLConnecion classes and feed it to the ScriptEngine. There is a tutorial here.

Categories

Resources