executable jar - Java Desktop Application - memory -


i'm creating java desktop application(runnable jar file). i'm getting path user when running first time (like workspace in eclipse).

i want application remember path when i'm closing application , running again (like eclipse remembering workspace).

but cant because everytime when close application , running again variables reinitialized.

eclipse desktop application. how eclipse doing , how can implement in application.

as suggested berger can use preferences api as:

public static void main(string[] args) {     try (scanner in = new scanner(system.in)) {         preferences userroot = preferences.userroot();         string workspace = userroot.get("workspace", null);         if (null != workspace) {             system.out.println(workspace);             system.out.println("would change value (y/n):");             string option = in.nextline();             if ("y".equals(option) || "y".equals(option)) {                 updateworkspace(in, userroot);             }         } else {             updateworkspace(in, userroot);         }     } catch (exception e) {         e.printstacktrace();     } }  private static void updateworkspace(scanner in, preferences userroot) {     string workspace;     system.out.println("enter value workspace:");     workspace = in.nextline();     userroot.put("workspace", workspace); } 

this sample example. based on need can make changes accordingly.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -