Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Command line arguments in jar files  (Read 2356 times)
0 Members and 1 Guest are viewing this topic.
Offline barfy

Junior Devvie




The evidence of things not seen


« Posted 2004-08-10 02:57:45 »

My jar'ed app needs more than the default maximum heap size of 64 megs.

How do I:

1. Run the jar'ed application deployed via webstart specifying the minimum and maximum heap sizes allocated similar to the effect achieved with this command line "java -Xms64m -Xmx128m MyClass"?

Thanks  Smiley
Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2004-08-10 05:44:34 »

Something like:

<j2se version="1.4" initial-heap-size="64M" max-heap-size="128M"/>

in your JNLP will sort you out.

Kev

Offline barfy

Junior Devvie




The evidence of things not seen


« Reply #2 - Posted 2004-08-10 15:19:49 »

Thanks for the answer Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Bombadil

Senior Devvie





« Reply #3 - Posted 2004-10-26 07:32:10 »

I've got the same question but without the Webstart option. :-)
Ie: I've got one startable JAR file which however needs more than 64 M.

I guess it's impossible to tell "inside" a JAR the max memory size (because the VM is already running...) ?

However I'd need right that. I don't use two JARs. Maybe there's some trick? A class inside the one JAR could start another class inside the same JAR but with a new and larger memory VM ...?
Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #4 - Posted 2004-10-26 07:53:22 »

I believe you'd need to start up a second VM from inside the first with a the appropriate settings.

However, if you know for sure you're running from the shell/OS then you could just add a script file .bat/.sh whatever which sets the appropriate settings.

Or you could consider this, which I find quite nice:

http://jsmooth.sourceforge.net/

Kev

Offline Bombadil

Senior Devvie





« Reply #5 - Posted 2004-10-26 10:18:25 »

Quote
I believe you'd need to start up a second VM from inside the first with a the appropriate settings.

Yes, indeed.
Something like...
Quote

Process p = Runtime.getRuntime().exec("java -Xmx128M -jar Jarfilename.jar -secondstart");

... works (by querying the param I see if it's already the second invocation with lots of RAM). Although it looks a little bit like overkill to me.

Is there a nice way to find out the name of the JAR from within which "I" am running?
Being at that, is it possible to see if "I" am being called from outside a JAR, ie from class files lying inside a "normal" folder?

Quote
However, if you know for sure you're running from the shell/OS then you could just add a script file .bat/.sh whatever which sets the appropriate settings.

Yes, I'm aware of this but tried to avoid if possible (it is, as I see now).

Quote
Or you could consider this, which I find quite nice:

I'm happy not to use Exes. ;-)

Thanks for your hints.
Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #6 - Posted 2004-10-26 10:21:15 »

If you use

URL me = getResource("myclassnamehere");

The URL should contain the name of the jar file (if any). Infact some the accessors on URL can probably be used to pull it out.

Kev

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #7 - Posted 2004-10-26 10:43:17 »

Don't use the "-secondstart" argument.  Just query the size of the heap at runtime.  If it is enough then you don't need to start a second instance with the memory params specified.

Why are you against a launcher stub (exe)??  After all that's what java.exe is Smiley.   Perhaps you should consider WebStart?

Offline Bombadil

Senior Devvie





« Reply #8 - Posted 2004-10-26 12:22:00 »

Quote
Don't use the "-secondstart" argument.  Just query the size of the heap at runtime.  If it is enough then you don't need to start a second instance with the memory params specified.

Another good idea. Thanks for the input.

Quote
Why are you against a launcher stub (exe)??

You as a Mac user are asking me this? Lol.
I love pure Java apps, no exe, no nothing. Virtual byte code rules. Compiled native code is nonflexible and ancient. :-)

Quote
After all that's what java.exe is :)

But this belongs to the JVM which has to be installed anway. However my app should run on any Java enabled platform unmodified.

Quote
Perhaps you should consider WebStart?

For a game, well yes, maybe.
For game tools I prefer one clickable JAR.

@Kev: smart idea, thanks.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #9 - Posted 2004-10-28 08:51:16 »

Quote
Something like... Quote:

Process p = Runtime.getRuntime().exec("java -Xmx128M -jar Jarfilename.jar -secondstart");
     
... works (by querying the param I see if it's already the second invocation with lots of RAM). Although it looks a little bit like overkill to me.


It would kind of work, provided that doubleclicking a jar works at all!
On my system, it opens power-archiver and I prefer my system like that.
My advice is to simply not depend on a jar being executable by itself and provide start scripts. Or even better, jws of course Smiley.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #10 - Posted 2004-10-28 09:02:07 »

Na, thats not right is it? The double clicking on a jar is a file association not a command line switch.

If you run "java -jar <jar>" explcitly it will always work. Running the java.exe isn't about to start up power-archiver.

Kev

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #11 - Posted 2004-10-28 09:30:42 »

That's not what I meant.
My point is that you can't depend on having the file association and therefor you can't depend on the jar file being double-clickable in the first place. So the code might work, but you might have to run the program manually anyway, making the extra code to start another jvm a bit pointless...

Offline Bombadil

Senior Devvie





« Reply #12 - Posted 2004-10-28 10:08:26 »

When a user installs J2SE (JRE), it does make a JAR double-clickable.
So when somebody tells me he can't double-click my JAR, I'll tell him to re-install Java.
If this also doesn't work, I'll tell him to re-install Winblows. ;-)

Delivering some mini starter script file (.bat and .sh) is still a good additional option, I agree.
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #13 - Posted 2004-10-28 10:30:16 »

Quote
When a user installs J2SE (JRE), it does make a JAR double-clickable.

Is this a part of the java standard or is this a Sun specific implementation thing? I think it's the latter which means your suggestion to re-install things would not be a very good one (I seem to remember the IBM jre installation not to make the file association, but I'm not sure)

Offline kevglass

« JGO Spiffy Duke »


Medals: 221
Projects: 24
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #14 - Posted 2004-10-28 10:36:55 »

Quote

That's not what I meant.


Doh! Sorry, read it wrong. Thought it was a bit of a large oversight Smiley

Kev

Offline Bombadil

Senior Devvie





« Reply #15 - Posted 2004-10-28 11:25:16 »

Quote

Is this a part of the java standard or is this a Sun specific implementation thing? I think it's the latter which means your suggestion to re-install things would not be a very good one (I seem to remember the IBM jre installation not to make the file association, but I'm not sure)

Good question. Unfortunately I don't know.

These are things... With M$-Dotnet they wrap their bytecode within an Exe which then calls via native code the VM... (Another reason I love pure Java files like JAR: no contamination with native code.)

But well, I'll give my JAR with a starter script (.bat / .sh) to my friends and in case the JAR isn't double clickable I'll tell them to double click the .bat ... (Hey presto: what if some Powerarchiver steals that extension, hehe...)
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #16 - Posted 2004-10-28 11:42:47 »

Quote
(Hey presto: what if some Powerarchiver steals that extension, hehe...)


Hey, file associations are *meant* to be stolen Smiley

Offline swpalmer

JGO Coder


Exp: 12 years


Where's the Kaboom?


« Reply #17 - Posted 2004-10-29 23:08:31 »

Quote

You as a Mac user are asking me this? Lol.
I love pure Java apps, no exe, no nothing. Virtual byte code rules. Compiled native code is nonflexible and ancient. :-)


As a Mac user I expect to have an Application Bundle.
As a Windows user I expect to start an .exe file
As a Linux user I expect to spend several days reconfiguring my system and compiling from source to get something that almost works. :D

Seriously though.  Platform independant code is all wonderful, but user experience counts for something too.  Windows users don't expect .jars to be programs.  Only Java programmers know that.  Get WebStart to make a proper shortcut for you that hides this detail, or use a cross-platform installer such as InstallAnywhere which will make the appropriate launcher for you.

Don't use InstallAnywhere for a Mac version though. It packages Java apps on a Mac in a very non-Mac way instead of simply making an Application Bundle like you are supposed to on the Mac.

You can make a Mac application bundle on Linux or a PC, you just need a copy of the JavaApplicationStub.  I do this on Windows all the time.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Mr.CodeIt (9 views)
2014-12-27 04:03:04

TheDudeFromCI (13 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (83 views)
2014-12-05 12:39:02

SHC (94 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!