0

I want to increase the initial RAM allocated to run a particular jar that needs it. However, passing the parameter "-xms1g" to the system JRE seems to prevent the launch of a JNLP file that I need to submit credentials for access to the U.S. Patent Office Private PAIR website:

https://ppair.uspto.gov/TruePassWebStart/AuthenticationChooser.html > "Authenticate with Java Web Start (new method)".

When the JNLP launches properly, it opens a GUI that prompts you to entire the filename and path of a certificate in one field, and a password in another field, and then it automatically closes and brings up the private PAIR website in your web browser, if your credentials are valid. You don't have to have a certificate or password to duplicate or test for my issue, as my problem is not getting the prompt to pop up.

For consistent testing and development of my jar, I want to run it on the latest JRE release, which I have to assume other users of my jar will be running. I believe I may also need to use the latest JRE release when launching the JNLP to access the USPTO, for security reasons. Maybe someone who understands cyber-security better than I do could tell me that JRE version doesn't matter when I am launching a JNLP file instead of running an applet through the Java browser plugin (the so-called "old method"), the latter plugin being what Google Chrome stopped supporting, but I don't want to assume that.

So ideally I would like to have two installed instances of the same (latest) JRE version and pass the -xms1g parameter only to the instance I use to run my jar, not to the (system) instance that launches the JNLP. Is this possible? When I tried executing the JRE installer twice, selecting different folders, I found that the second installation had deleted everything from the first folder.

PatentWookiee
  • 187
  • 2
  • 17
  • 1
    I don't see why you would need two separate installations of the same JRE. JVM options such as `-xms1g` are characteristic of a JRE *process*, specified (or defaulted) at runtime, not characteristic of a JRE *installation*. – John Bollinger Dec 14 '17 at 20:12
  • 1
    Note also that although yes, you should test your application on the latest JRE, in practice, many users will be using other versions, some of them very old indeed. You should not neglect testing some of those. – John Bollinger Dec 14 '17 at 20:14
  • Thanks @JohnBollinger. I am a Java coding novice. I had been setting -xms1g as a runtime parameter in the Windows Java control panel (Java Control Panel > Java > View > Runtime Parameters). Your comment led me to discover the idea of putting a batch file in the folder where MyApp.jar is stored, containing the line "java -Xms1g -jar MyApp.jar", as in kravi's answer to the following stale question https://stackoverflow.com/questions/1018217/can-i-set-java-max-heap-size-for-running-from-a-jar-file. – PatentWookiee Dec 14 '17 at 20:59
  • That would be an acceptable answer if it works. – PatentWookiee Dec 14 '17 at 21:03

1 Answers1

1

So ideally I would like to have two installed instances of the same (latest) JRE version and pass the -xms1g parameter only to the instance I use to run my jar, not to the (system) instance that launches the JNLP. Is this possible? When I tried executing the JRE installer twice, selecting different folders, I found that the second installation had deleted everything from the first folder.

You do not need two installations of the same JRE to run different java processes with different options. Ensuring that is the purpose of providing them as command-line options. You can choose the non-default options you want when you launch the JVM, whether by configuring them in a shortcut, recording them in a launch script (taking the form of a batch file on Windows), or typing them manually on the command line.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157
  • This seems to work - in the "Target" field of the shortcut I put `<>javaw.exe -jar "<>.jar" -xms1g `, and it launches the jar just fine. I am not 100% certain that insufficient RAM was causing my jar to choke on some larger tasks, so it is hard to confirm whether it is allocating the RAM I asked it to, but I assume it is. – PatentWookiee Dec 18 '17 at 19:07
  • 1
    No, @PatentWookiee, the `-xms1g` should come before `-jar`: `javaw.exe -xms1g -jar "<>.jar"`. In that position, the JVM launcher (`javaw.exe` in this case) interprets it itself. If it appears after the jar name then it is passed as an argument to the Java program's `main()` method. – John Bollinger Dec 18 '17 at 20:13