libgdx suddenly stopped being able to load images/textures? - java

So I fired up IntelliJ and created a new libgdx project, imported it and everything and then I tried to run the DesktopLauncher to see if it would work and I got this error message:
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:88)
at com.blobb.game.PongGame.create(PongGame.java:16)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:220)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
... 9 more
Process finished with exit code 0
It was working fine before, plus I checked the assets folder in both "core" and "android" folders and they both had the badlogic.png file in them. What could be going on?

I guess you set everything up according to tutorials so I assume that everything was initially correct. Nevertheless some things like linked Assets folder is simply not imported.
You can try the method described here. To be honest I didn't tried it myself but some people were successfully using it.
(See here for a discussion concerned with your problem in general)

Related

JavaFX | I want to use different packages in a JavaFX project

I tried creating a JavaFX project in Eclipse and as long as I didn't change the default file location everything worked fine.
This is the newly craeted project
I want instead to put the SceneControllers in a different package from Main, and .fxml files in another package.
I want it to become more like this
Expected folders
But when i run the app i get this error
`
java.lang.NullPointerException: Location is required.
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3324)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3287)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3255)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3227)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3203)
at javafx.fxml#19/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3196)
at application.classes.Main.start(Main.java:14)
at javafx.graphics#19/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics#19/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics#19/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics#19/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics#19/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics#19/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics#19/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
`
So i tought the issue was to specify the location of the "Sample.fxml" file, and at line 14 wrote:
AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("../Sample.fxml"));
And got this error:
`
javafx.fxml.LoadException:
/C:/Users/ultra/eclipse-workspace/Shopping%20Online/bin/application/guifiles/Sample.fxml:5
at javafx.fxml#19/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
at javafx.fxml#19/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:933)
at javafx.fxml#19/javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:981)
at javafx.fxml#19/javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:230)
at javafx.fxml#19/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:755)
at javafx.fxml#19/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2808)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2634)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3331)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3287)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3255)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3227)
at javafx.fxml#19/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3203)
at javafx.fxml#19/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3196)
at application.classes.Main.start(Main.java:14)
at javafx.graphics#19/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
at javafx.graphics#19/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
at javafx.graphics#19/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at javafx.graphics#19/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
at javafx.graphics#19/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics#19/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics#19/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: application.SampleController
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at javafx.fxml#19/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:931)
... 22 more
`
The new error is
ClassNotFoundException: application.SampleController
which occurs when you try to load the FXML, specifically on line 5 of Sample.fxml.
When you moved your controller class SampleController from the application package to the application.controllers package, you changed its fully-qualified class name. So you need to change the fx:controller attribute in the FXML file (on line 5) accordingly:
fx:controller="application.controllers.SampleController"
As an aside, note that the resource path you are using for the FXML file is not valid, as .. is not a valid resource name. It might work while you are still running the application from the file system, but will not work if you bundle it as a jar file. See How do I determine the correct path for FXML files, CSS files, Images, and other resources needed by my JavaFX Application?

Error: NoClassDefFoundError When Using Eclipse To Run COMSOL Model

I am trying to use Eclipse to run a COMSOL model and I have read the guide from programming reference manual. However, Eclipse always report the error as follows,
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter at com.comsol.client.interfaces.b.(SourceFile:60) at com.comsol.client.interfaces.b.(SourceFile:39) at com.comsol.clientapi.engine.APIEngine$c.b(SourceFile:497) at com.comsol.clientapi.engine.APIEngine.a(SourceFile:115) at com.comsol.clientapi.engine.APIEngine.connect(SourceFile:98) at com.comsol.clientapi.engine.APIEngine.connect(SourceFile:87) at com.comsol.clientapi.engine.ClientModelUtil.connect(SourceFile:145) at com.comsol.clientapi.engine.ClientModelUtil.connect(SourceFile:133) at com.comsol.model.util.ModelUtil.connect(SourceFile:248) at PFCZM_3PBending_QuasiBrittle.main(PFCZM_3PBending_QuasiBrittle.java:16750) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519) ... 10 more
I believe I have imported the JAR files correctly and set the path for the project and it seems that the error is due to lack of source file for COMSOL API JAR files. I have checked those JAR file and found they are indeed all class files without definition. How can I solve this problem? Thanks!

Debugging a Unity Android "Unable to convert classes into dex format" error on build

I've been having trouble doing an Unity Android build because of these dex format errors.
I've looked at similar errors people have had with this involving duplicate .jar files in the Unity project, but I've removed all the culprits I can find and this is still happening. I recently updated the unity Facebook plugin and there are several other plugins in the project as well, so I know I would be prone to have some duplicate files.
I can see there a lot of "illegal argument exception" already added translations errors, so I'm assuming something is getting referenced twice, but I can't figure out where these "accessibility service" files are.
I'll admit the rest of the error I'm still trying to figure out. I'm not a super experienced java/android developer just yet.
Does anyone know what might be wrong? Or have any ideas of how I might go debugging this error further?
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Users/Admin/Public_Library/Android/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/Unity.app/Contents/BuildTargetTools/AndroidPlayer/sdktools.jar" -
stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoIcsImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoJellyBeanMr2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoStubImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatJellyBeanMr2;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActionBarDrawerToggle;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/ActionBarDrawerToggle$1;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at SDKMain.main(SDKMain.java:130)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
... 9 more
]
I was wrong, it looks like I still had a duplicate .jar file in the project. There were two .jar files with different names from two different social plugins but they were same functionality.
You need remove: Assets/Game/Plugins/Android/android-support-v4.jar

Exporting java program with processing elements to executable jar

I have a java project with processing elements that compiles and runs fine inside of Eclipse, but I need to export it to an executable. When I do this via Eclipse's export wizard, it produces a jar, but that jar produces runtime errors when it's double clicked or called from the command line. First it was giving me this:
C:\Users\Rachel\School\MQP>java -jar Simworm14.jar
Catched MalformedURLException: Could not open InputStream for URL 'rsrc:gluegen-
rt-natives-windows-amd64.jar', while addNativeJarLibsImpl(classFromJavaJar class
com.jogamp.common.os.Platform, classJarURI jar:rsrc:gluegen-rt.jar!/com/jogamp/
common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-windows-amd64.jar
): [ rsrc:gluegen-rt.jar -> rsrc: ] + gluegen-rt-natives-windows-amd64.jar -> sl
im: jar:rsrc:gluegen-rt-natives-windows-amd64.jar!/
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: Can't loa
d library: C:\Users\Rachel\School\MQP\gluegen-rt.dll
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1706)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoad
erBase.java:551)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.ja
va:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNIL
ibLoaderBase.java:96)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.j
ava:414)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrar
y(DynamicLibraryBundle.java:388)
at com.jogamp.common.os.Platform$1.run(Platform.java:203)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:173)
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
at processing.opengl.PJOGL.initSurface(PJOGL.java:250)
at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:62
44)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:16
25)
at processing.core.PApplet.run(PApplet.java:2177)
at java.lang.Thread.run(Thread.java:662)
So I tried pasting gluegen-rt.dll into the given directory, and then it gave me this error instead:
C:\Users\Rachel\School\MQP>java -jar Simworm14.jar
Catched MalformedURLException: Could not open InputStream for URL 'rsrc:gluegen-
rt-natives-windows-amd64.jar', while addNativeJarLibsImpl(classFromJavaJar class
com.jogamp.common.os.Platform, classJarURI jar:rsrc:gluegen-rt.jar!/com/jogamp/
common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-windows-amd64.jar
): [ rsrc:gluegen-rt.jar -> rsrc: ] + gluegen-rt-natives-windows-amd64.jar -> sl
im: jar:rsrc:gluegen-rt-natives-windows-amd64.jar!/
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: C:\Users\
Rachel\School\MQP\gluegen-rt.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoad
erBase.java:551)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.ja
va:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNIL
ibLoaderBase.java:96)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.j
ava:414)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrar
y(DynamicLibraryBundle.java:388)
at com.jogamp.common.os.Platform$1.run(Platform.java:203)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:173)
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
at processing.opengl.PJOGL.initSurface(PJOGL.java:250)
at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:62
44)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:16
25)
at processing.core.PApplet.run(PApplet.java:2177)
at java.lang.Thread.run(Thread.java:662)
After some googling, it appears this dependency issue might be a bug with jogl: https://java.net/jira/browse/JOGL-346 but I find it hard to believe that nobody has been able to export any processing applications from Eclipse. There's got to be a way, hasn't there?
Any suggestions?
Processing requires native libraries, which it doesn't look like you're including. You need to at least put the JOGL jar for the system you're on, but that won't help you deploy to other systems.
Shameless self-promotion: I wrote a tool that helps you create self-extracting runnable jar files that handle Processing's native libraries automatically so it works on every system: http://StaticVoidGames.com/SvgExe/

Trying to play a MP3 file using javazoom and getting an error saying "unable to load resource 'sfd.ser"

This is the error that I'm getting:
Exception in thread "Thread-4" java.lang.ExceptionInInitializerError
at javazoom.jl.decoder.SynthesisFilter.load_d(SynthesisFilter.java:1626)
at javazoom.jl.decoder.SynthesisFilter.<init>(SynthesisFilter.java:75)
at javazoom.jl.decoder.Decoder.initialize(Decoder.java:283)
at javazoom.jl.decoder.Decoder.decodeFrame(Decoder.java:138)
at javazoom.jl.player.Player.decodeFrame(Player.java:213)
at javazoom.jl.player.Player.play(Player.java:120)
at javazoom.jl.player.Player.play(Player.java:104)
at exetersoundsystem.back.mp3_player$AdvancedPlayerThread.run(mp3_player.java:192)
Caused by: java.io.IOException: unable to load resource 'sfd.ser'
at javazoom.jl.decoder.JavaLayerUtils.deserializeArrayResource(JavaLayerUtils.java:146)
at javazoom.jl.decoder.SynthesisFilter.load_d(SynthesisFilter.java:1621)
... 7 more
I goggled it a bit and I was told to change some policy for some file, but I'm totally lost on what to change.
I guess it's a serial number - did they change the license?
I wrote a pure java mp3 player: mp3transform - it is based on JLayer from JavaZoom when it was still LGPL.

Categories