Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Sep 2008
    Thanked 0 Times in 0 Posts

    Saving data in java applets

    I'm working on a 2D game, and I'm not sure if I want to do it in applet or application format. Applet seems ideal, because it's a relatively small game, and applets are more convenient to share, but can applets save data? I've always outputted to a text file to save games, and I don't know if there's some function to save data in an applet. If it isn't possible to do this, then I'd definitely better off using the application format, but I'd like to try an applet if possible.

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Thanked 76 Times in 76 Posts
    No, not possible. Applet has to be signed in order to do that (save to disk), doubt that you will buy expensive certificate only for your purpose.

    Unfortunately even embeded resource (like embeded txt file) in applet can't be changed at runtime, if you willl get to that idea.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #3
    Codeasaurus Rex
    Join Date
    Jun 2008
    Redmond, WA
    Thanked 100 Times in 94 Posts
    A few methods when it comes to applets.

    A) As BubikolRamios pointed out signing is an option. Believe it or not it is actually possible to sign your own applets, but it generates a ton of warnings and things for the end user.

    B) Run your applet and have it save data to a remote database. You can run database commands through a secure API you set up which validates that what is being transacted is valid. It is, however, possible to intercept and manipulate game data in this manner (but so is writing to a text file).

    C) Make the applet an executable JAR/JNLP. Create a jar (Guide) which can then be executed. When it comes to sensitive permissions the user will be prompted to give the OK to allow the applet to access system resources. Same goes for a JNLP, but a JNLP allows you to update the game content remotely and have it automatically downloaded to the person when they execute the file.
    Unless otherwise stated, any code posted is most likely untested and may contain syntax errors.
    My posts, comments, code, and suggestions reflect only my personal views.
    Web Portfolio and Code Snippets: http://shanechism.com


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts