3 Replies - 403 Views - Last Post: 25 April 2019 - 07:58 AM Rate Topic: -----

#1 Larry71   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 66
  • Joined: 05-June 12

Running .jar with parameters

Posted 20 April 2019 - 01:07 PM

I am ready to publish an application that comes as a .jar file.

What the problem is : The jar file must use at least 1 gb memory to run. I know that this must be done through cmd line, but I am pretty sure that most of the users don't have this skill and I also find it not appropriate to ask them to do that.

What I thought of, is make another jar as gui, that will put the application .jar at the desired, or make new, folder and give the application the needed memory.

Can someone guide me or propose something else?

Please feel free to move this question to the right place, if it doesn't belong here.

Is This A Good Question/Topic? 0
  • +

Replies To: Running .jar with parameters

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3623
  • View blog
  • Posts: 16,656
  • Joined: 20-September 08

Re: Running .jar with parameters

Posted 21 April 2019 - 04:33 AM

This is the kind of thing that Java Web Start was meant to make easier but guess what - it's going to be dropped
At this stage, Java is so volatile, especially on the desktop, that i'd go old style and use an installer. If you're lucky you might find a free (and open source) one
Was This Post Helpful? 0
  • +
  • -

#3 Jordy2254   User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 58
  • Joined: 18-October 14

Re: Running .jar with parameters

Posted 25 April 2019 - 05:37 AM

Hello,

Another way you could do this is create a script file for start up, both for linux, windows and mac:

Windows uses a batch script nice and easy to setup and get going
Linux uses a shell script again resnobly easy to get setup, however needs some stuff done by end user but linux/ubuntu user's will be able to do this.

MAC: I don't use them so not sure what they use.

Then when distributing your jar package it in a zip with the jar file and the batch files. the end user can then decompress and run through the batch. Add a check in your main function to pop up an error if it's started using the wrong ammount of memory, off the top of my head usiung the java runtime the following code would give you the available memorty for the program in bytes.

long aMem = (Runtime.getRuntime().totalMemory()-Runtime.getRuntime().freeMemory());


Or as gOOse said you could use an open source installer to create an installer for it instead.

hope this helps
Jordan
Was This Post Helpful? 1
  • +
  • -

#4 Larry71   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 66
  • Joined: 05-June 12

Re: Running .jar with parameters

Posted 25 April 2019 - 07:58 AM

I used Launch4J to do the job.

It can take parameters like jre, heap memory and creates an .exe file.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1