Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Command-line options in a jar file

Reply
Thread Tools

Command-line options in a jar file

 
 
Jan Burse
Guest
Posts: n/a
 
      04-21-2012
Hiram Hunt schrieb:
> trying to do. I don't see in the ProcessBuilder documentation


http://silentdevelopment.blogspot.co...ap-memory.html
 
Reply With Quote
 
 
 
 
Hiram Hunt
Guest
Posts: n/a
 
      04-22-2012

"Jan Burse" <(E-Mail Removed)> wrote in message
news:jmvg0g$v3l$(E-Mail Removed)...
> Hiram Hunt schrieb:
>> trying to do. I don't see in the ProcessBuilder documentation

>
> http://silentdevelopment.blogspot.co...ap-memory.html


Okay. Thanks. I think what I was missing is that ProcessBuilder
sets things up for a general process, not just something that you
start with java.exe. Thus, if the general process you start is
java.exe itself, you can pass any arguments you wish to it
including the memory allocation argument.

-- Hiram Hunt


 
Reply With Quote
 
 
 
 
Arne Vajh°j
Guest
Posts: n/a
 
      04-22-2012
On 4/21/2012 5:27 PM, Hiram Hunt wrote:
> "Lew"<(E-Mail Removed)> wrote in message
> news:jmv4la$b2f$(E-Mail Removed)...
>> On 04/21/2012 12:11 PM, Hiram Hunt wrote:
>>> #jar cfe hi.jar hi.HelloWorld hi\HelloWorld.class -J-showversion
>>> java version "1.7.0_03"
>>> Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
>>> Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)
>>>
>>>
>>> #ftype jarfile
>>> jarfile="C:\Program Files\Java\jre7\bin\java.exe" -jar "%1%" %*
>>>
>>> #hi.jar
>>> Hello, world
>>>
>>> #
>>>
>>> Is there a way to (in this example) get the version information
>>> to show up when running hi.jar instead of when running jar itself?

>>
>> Version of what? Java itself, as you show here? What's wrong with using
>> the "java" command for that?

>
> I used -version to demonstrate the problem I was having getting a
> command-line option to be saved in a jar file for use when the
> jar file is executed. The specific option I used for the demonstration
> was just a convenient example, because the results can easily be
> seen. As I said before, the options I actually care about (today, anyway)
> are -Xmxn and -Dthis=that (with appropriate values to be substituted
> for "n" and "this=that").


Executable jar files does not support JVM args in manifest.

You options are:
1) specify the JVM args in the command line (does not work with
double click)
2) write a startup script (this is very common)
3) write your own startup executable that create the JVM with
the args you want (requires a build per supported platform)

Arne


 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      04-22-2012
On Sat, 21 Apr 2012 15:11:14 -0400, "Hiram Hunt"
<(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
said :

>Hello,
>
>Is there a way to pass command-line options to java.exe
>with an executable jar file?


There is no way to put command line arguments destined for java.exe
inside the jar in the manifest. However, if you use JWS, you can put
them in the JNLP file which lives outside the jar. The reason for this
is, by the time the java.exe JVM (Java Virtual Machine) gets around to
looking inside jars, it has already cast in stone everything it
learned from the command line.

~ http://mindprod.com/jgloss/jar.html#MANIFEST
--
Roedy Green Canadian Mind Products
http://mindprod.com
When you were a child, if you did your own experiment
to see if it was better to put to cocoa into your cup first
or the hot milk first, then you likely have the programmer gene..
 
Reply With Quote
 
Hiram Hunt
Guest
Posts: n/a
 
      04-22-2012
"Roedy Green" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Sat, 21 Apr 2012 15:11:14 -0400, "Hiram Hunt"
> <(E-Mail Removed)> wrote, quoted or indirectly quoted someone who
> said :
>
>>....

>....


Thanks.

-- Hiram Hunt


 
Reply With Quote
 
Hiram Hunt
Guest
Posts: n/a
 
      04-22-2012
"Arne Vajh°j" <(E-Mail Removed)> wrote in message
news:4f936764$0$285$(E-Mail Removed)...
> On 4/21/2012 5:27 PM, Hiram Hunt wrote:
>> ....

> ....


Thanks.

-- Hiram Hunt


 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      04-22-2012
In article <4f934c5e$0$27555$c3e8da3$(E-Mail Removed) om>,
"Hiram Hunt" <(E-Mail Removed)> wrote:

> I think what I was missing is that ProcessBuilder sets things up for
> a general process, not just something that you start with java.exe.
> Thus, if the general process you start is java.exe itself, you can
> pass any arguments you wish to it including the memory allocation
> argument.


See also this gui.Launcher:

<http://groups.google.com/group/comp.lang.java.programmer/msg/c81f8c5f269e22e5>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
Hiram Hunt
Guest
Posts: n/a
 
      04-22-2012
"John B. Matthews" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In article <4f934c5e$0$27555$c3e8da3$(E-Mail Removed) om>,
> "Hiram Hunt" <(E-Mail Removed)> wrote:
>
>> I think what I was missing is that ProcessBuilder sets things up for
>> a general process, not just something that you start with java.exe.
>> Thus, if the general process you start is java.exe itself, you can
>> pass any arguments you wish to it including the memory allocation
>> argument.

>
> See also this gui.Launcher:
>
> <http://groups.google.com/group/comp.lang.java.programmer/msg/c81f8c5f269e22e5>
>

Thanks. Having a GUI to launch the process is more than I need, but just
looking over the code makes me a bit more comfortable with the concept
of trying ProcessBuilder for my program.

-- Hiram Hunt


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM
how to disassembly a .jar file? how to see what are the classes inside the .jar file? lucy Java 6 09-07-2004 09:54 PM



Advertisments