Libgdx game making tutorial (Drop) Iterator<Rectangle> - java

So i'm very new to libgdx and i were doing the drop tutorial that is at the libgdx wiki.So when i finished i got an error on line 98 at Iterator<Rectangle> iter = raindrops.iterator();
More specifically it says :
The type HTMLDocument.iterator is not genetic; it cannot be
parameterized with arguments <Rectangle>
Also in the console i get this :
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.Error: Unresolved compilation problem:
The type HTMLDocument.Iterator is not generic; it cannot be parameterized with arguments <Rectangle>
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
Caused by: java.lang.Error: Unresolved compilation problem:
The type HTMLDocument.Iterator is not generic; it cannot be parameterized with arguments <Rectangle>
at com.mygdx.test.Test.render(Test.java:98)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:206)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
I really dont know why i get this error if you know the solution i would really appreciated help. Thanks for your time.

Seems like you accidentally added a wrong import!
You need to import:
import java.util.Iterator;
Instead of:
import javax.swing.text.html.HTMLDocument.Iterator;
because the class HTMLDocument.Iterator is not used at all in the libgdx drop tutorial

I believe this is because of the html project not automatically being set up properly. Maybe try this

Related

AndroidJavaObject initialization fails NoSuchMethodError

The error: AndroidJavaException: java.lang.NoSuchMethodError: no non-static method "Ljava/util/UUID;.(J)V"
The code: var psshUuid = new AndroidJavaObject("java.util.UUID", 0x1077EFECC0B24D02L, 0xACE33C1E52E2FB4BL);
java.util.UUID takes two longs in its constructor - I'm not sure what I'm doing wrong here. This is in Unity, coding in C#. Also, does anyone know what the (J)V part of the error means?
Turns out Java didn't like that these numbers are technically ulongs.

How to load saved model created by (Weka GUI) into my java application and browse the predicted result

My model is done using "FilteredClassifier" algorithm, then SMO as a
"classifier" parameter. "weka.classifiers.functions.SMO".
I tried to load my model into java using this code but it is not work
SupportVector SOM = (SupportVector) SerializationHelper.read(new
FileInputStream("C:\\Users\\HP\\Desktop\\SOM.model"));
and this code
FilteredClassifier SOM = (FilteredClassifier )
SerializationHelper.read(new
FileInputStream("C:\\Users\\HP\\Desktop\\SOM.model"));
both not working
then I want to browse the data used in building this model (actual value and predicted value).
how I can do it? Once I have created the model, do I need to load the dataset again?
This is the error
Exception in thread "main" java.lang.ClassCastException: weka.classifiers.meta.FilteredClassifier cannot be cast to weka.core.pmml.jaxbbindings.SupportVector
at weka.api.Model.main(Model.java:28)
This is the error
Exception in thread "main" java.lang.ClassCastException: weka.classifiers.meta.FilteredClassifier cannot be cast to weka.core.pmml.jaxbbindings.SupportVector
at weka.api.Model.main(Model.java:28)
weka.classifiers.meta.FilteredClassifier cannot be cast to weka.core.pmml.jaxbbindings.SupportVector
pmml and jaxb are XML related classes, you appear to have imported the wrong package.

How to put javaScript code in Java program/application?

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.

Error ClassCastException: [Ljava.lang.Object; cannot be cast to [Lcom.happydroids.droidtowers.entities.GridObject;

I'm trying to compile the following project: https://github.com/pplante/droidtowers
(the December 02 version, which is the last one that works). I managed to get all the dependencies etc and it compiles both under eclipse and IntelliJ-IDEA (which is the original project). However, when running under eclipse the following error appears at this line:
Array<GridObject> rooms = new Array<GridObject>(gameGrid.getInstancesOf(Room.class).items);
This crashes the game after a new game is started, past the Main Menu.
Now, I know that the Room class extends GridObject, and this runs fine under IntelliJ. I can't wrap my head around what can be the problem, or difference between both executables, so any help would be welcome. Maybe there's a default in the compiler overriden in the IDEA project? (I made the eclipse project from scratch).
This is using the latest Java, and android sdk.
ADDENDUM: Here's the full stacktrace:
ago 05, 2013 3:14:57 PM com.happydroids.platform.DesktopUncaughtExceptionHandler uncaughtException
SEVERE: Uncaught exception!
com.badlogic.gdx.utils.GdxRuntimeException: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lcom.happydroids.droidtowers.entities.GridObject;
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111)
Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lcom.happydroids.droidtowers.entities.GridObject;
at com.happydroids.droidtowers.controllers.AvatarLayer.setupInitialAvatars(AvatarLayer.java:191)
at com.happydroids.droidtowers.scenes.TowerScene.create(TowerScene.java:145)
at com.happydroids.droidtowers.scenes.components.SceneManager.pushScene(SceneManager.java:39)
at com.happydroids.droidtowers.scenes.components.SceneManager.changeScene(SceneManager.java:26)
at com.happydroids.droidtowers.scenes.LoadTowerSplashScene.render(LoadTowerSplashScene.java:29)
at com.happydroids.droidtowers.DroidTowersGame.render(DroidTowersGame.java:216)
at com.happydroids.droidtowers.LwjglApplicationShim.render(LwjglApplicationShim.java:50)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:190)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:108)
com.badlogic.gdx.utils.GdxRuntimeException: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lcom.happydroids.droidtowers.entities.GridObject;
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:111)
Caused by: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lcom.happydroids.droidtowers.entities.GridObject;
at com.happydroids.droidtowers.controllers.AvatarLayer.setupInitialAvatars(AvatarLayer.java:191)
at com.happydroids.droidtowers.scenes.TowerScene.create(TowerScene.java:145)
at com.happydroids.droidtowers.scenes.components.SceneManager.pushScene(SceneManager.java:39)
at com.happydroids.droidtowers.scenes.components.SceneManager.changeScene(SceneManager.java:26)
at com.happydroids.droidtowers.scenes.LoadTowerSplashScene.render(LoadTowerSplashScene.java:29)
at com.happydroids.droidtowers.DroidTowersGame.render(DroidTowersGame.java:216)
at com.happydroids.droidtowers.LwjglApplicationShim.render(LwjglApplicationShim.java:50)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:190)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:108)
Well, can't say I "fixed" the error (apparently that's just the way generics work or something) but I removed ".items" and it worked, because it was redundant: it was basically taking a function that returns Array<GridObject>, it was converting it to an array GridObject[], then using a constructor to convert it back to a type Array<GridObject>.
The biggest mistery now is why IDEA didn't return an error at all. Could be some obscure compiler setting.

What are the standard externs provided by the command line Google Closure, and how do I get them through the Java interface?

I'm currently using this code:
com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.OFF);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
CompilerOptions options = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
List<JSSourceFile> externs = new ArrayList<JSSourceFile>();
externs.add(JSSourceFile.fromFile(extern_src));
List<JSSourceFile> primary = new ArrayList<JSSourceFile>();
primary.add(JSSourceFile.fromFile(tmp));
compiler.compile(externs, primary, options);
However, I get lots of errors like this:
Error message: JSC_UNDEFINED_VARIABLE. variable Array is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable TypeError is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Object is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable arguments is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Number is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Math is undefined
Obviously, these are not correct: things like Object and arguments etc a core part of the language. What can I do to fix this?
Did you see Michael Bolin blog regarding using the Java API?
http://blog.bolinfest.com/2009/11/calling-closure-compiler-from-java.html

Categories

Resources