0

I am creating a Simon Says memory sequence game that is created in Java Applet. I need to post it on a website and just be able to run it without using a java compiler. It has an Image folder and a Sound folder that need to be included in the .jar file.

Here is the link to some code.

Andrew Thompson
  • 163,965
  • 36
  • 203
  • 405
kwolff7
  • 15
  • 4
  • Those resources have become embedded resources once put into a Jar. See the [info. page for embedded resource](http://stackoverflow.com/tags/embedded-resource/info) for how to form a URL to an embedded resource. It will probably help to prefix every string with `/`. Then the `getImage(URL)` method can load the resource from the URL. – Andrew Thompson Jun 02 '15 at 06:12

1 Answers1

0

You have to pack all necessary files to this jar and use them as resources not files. See how it's done here.

Community
  • 1
  • 1
Alex
  • 4,408
  • 2
  • 16
  • 57
  • Given that Q&A is all about streams, whereas applets work well with URLs, I don't see it as being strongly relevant to this question.. – Andrew Thompson Jun 02 '15 at 06:13
  • @AndrewThompson OP says: "Sound folder that need to be included in the .jar file" - that's the reason I had suggested to use these files as resources and so as streams. – Alex Jun 02 '15 at 12:32
  • URLs can work for Jar files as well. ;) Note that among the [applet methods](http://docs.oracle.com/javase/8/docs/api/java/applet/Applet.html#method.summary), there is `getImage(URL)` and `getImage(URL, String)`, but no `getImage(InputStream)`. Of course, there are a number of other ways to load images from streams, but in my comment on the question, I recommended sticking with an URL for the sake of continuing to use the inbuilt applet methods. – Andrew Thompson Jun 02 '15 at 12:35