In Eclipse, where do I save files to make them available to a Java Applet?

I'm writing a Java applet and using Eclipse. What should the directory structure/build path/other configuration be so that I can use getResource() or ImageIcon with some relative path when running the applet in Eclipse's applet viewer? (I'll figure out later how to get it to work for when the applet is deployed.) Is some kind of project builder necessary?



Answer on In Eclipse, where do I save files to make them available to a Java Applet?



If you use getResource() the path should be relative to the source folder.



/src/

| -- resources

----| -- images

--------| -- img1.jpg

--------| -- img2.jpg

----| -- audio

| -- config

| -- org

----| -- music

--------| -- mp3

------------| -- decode



If I wanted to get the URL of img2.jpg:



URL imgURL = this.class.getResource(

"/resources/images/img2.jpg");

0 Response to "In Eclipse, where do I save files to make them available to a Java Applet?"

Posting Komentar

Postingan Populer