I have been having some difficulty in debugging my applets. Basically, none of my applets run from within eclipse, that's because i use methods that loads images from URL's. Basically i have to export the classes to a jar, manually add the images via 7zip, then build a container file to run the applet. If all goes well it runs. If i get an exception it doesn't run at all. Is there any way i can simplify my current debugging technique? To be honest it's not even debugging, it's just run and hope it compiles XD

When i pack up the classes in a jar with the image in the same directory it loads but if i run it in eclipse it can't find any image, therefore it results in a null pointer when it calls the getURL method.

My question is, where do i put the image files so eclipse can load em?

I know why it get's an exception, it's because it can't find pilenliten.png and Pilen_drogad.png, it only runs if i export it to a .jar, then open it with 7zip and add pilenliten.png and Pilen_drogad.png to the folder with the class files in the .jar, then start the .jar with a html file.

soory if it look too much schoolar but here is maybe a clarification that will help you :

in java ( and a cupple of other languages ) there are two main kinds of path : - compilation : everything used for compilation need to be in this one (and compilation will be fine) - runtime : everything needed to run your application Applet/Application need to be in this one (and running your application will be fine)

usually/often you got two main directories in a small project : sources & build, - in source folder you ususally got source files (only *.java source file, no need of images in this one) - in build you got class file & ressources (ressources include images aswell as config file and such etc...)

for your "bug" what seems wrong is that you dont get everything in your build folder (compilation run fine), so you have to found where the compilation is done and put ressources (Pilen_drogad.png , etc...) in it : images ( and maybe later other necessaries files)

With NetBeans I used to put my images directly in the src folder with the source code, and they would be automatically bundled into the jar. For running I had a helper class that could automatically wrap the applet within a JFrame.

I would have two cases: make your code load from the classpath and fall back to a configured file path. Either wrap the fallback in a try-catch to handle the SecurityException or put it in an if block guarded by a static final boolean which you can toggle to compile for debug or RC.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org