Command line options in Jar files?

Can I set a command line option in the manifest of my jar file so that when it is double clicked it will invoke the JVM with my command line option??

Trying to pass to the JVM, not my code.I see.
Actually I wish sun would just fix the dang option towork
as it should and not need to be on the commandline...
And that won't happen.
Your presumption is that the manifest could somehow do
the command line options. But by the time the
manifest and jar file is read, the JVM is already
running and fully functional. Most of the
functionality that you see in the jvm is actually
implemented by other java classes. So the JVM has to
be running before it can do anything.
With sun jdk 1.3 a hello world program loads 180+
classes. This is not pre-loading but rather load on
demand, it needs all of those classes to load, resolve
and run the hello world program.
Actually I am aware of the classes which implement this functionality. It would be VERY easy for sun to empty the connection cache, they just choose to not let us do it for whatever bonehead reason. ANYONE who uses an internet inabled java application/applet will have this issue. Is java supposedly internet friendly?
Just try it. unplug your internet, use a java application to try and connect to some URL (telnet, ftp, whatever). Plugin your internet connection and see that you will not be able to connect untill you restart your app.
Crazy. This should be implemented. Its got 2 be a bug. they dont even tell you its command line only...

Similar Messages

  • Include command line args in jar file

    If I make and executable jar file, how can I make it so that when it runs certain comman line arguments are included

    If by "executable jar" you mean that you want to click the jar and run the program (and are using Windows), then you would have to alter the Windows file association for jar files that Java created, adding those options to the javaw command. Note that that would affect all jars that are run this was.
    If you're willing to use the "javaw -jar" command, then just add the options to the javaw command.

  • JAVA command line options -cp and -jar don't work together?

    Running JSDK 1.4.2 under Windows. I have a Java application that tries to dynamically load a class name that the user enters as follows:
    try {
    classResult = java.lang.Class.forName(strFilterName);
    catch (ExceptionInInitializerError e) {
    strErrorMessage = "ExceptionInInitializerError loading class: " + strFilterName;
    catch (LinkageError e) {
    strErrorMessage = "LinkageError loading class: " + strFilterName;
    catch (ClassNotFoundException e) {
    strErrorMessage = "ClassNotFoundException loading class: " + strFilterName;
    This works fine if the classes that make up my application are left as class files in the classpath, but fails to work if they have been collected and run from a JAR file. Note: I can even dynamically load the class when running from the JAR file, if the class I'm trying to load is within that JAR file too. The problem really occurrs when the dynamically loaded class is located someplace else in my classpath. I've tried using various combinations of the "-cp" and "-jar" Java command line options - but when loading and running from a JAR file - the "-cp" parameters seem to be ignored. Is this a bug? Has anyone ever seen this before?
    I run my program from the JAR file using this command:
    java -cp .;e:\entmgr\filters -jar EntMgr.jar
    Where "e:\entmgr\filters" is where the class I'm trying to dynamically load is. (This class has no package name, but loads perfectly as long as I'm not running the application from the JAR file). The class name specified by the user has to be fully specified with a package name (if it has one).
    I have tried forcing the "java.lang.Class.forName(strFilterName);" call to use the system class loader, the parent of the system class loaded, and even the null bootstrap class loader - all with no success.
    I am suspecting that the class loader that is loading and running my main program from the JAR file, is just not paying any attention to the "-cp" parameter when the "-jar" parameter is present. Indeed, I have never seen any change in the failure, no matter what I put in the "-cp" parameter when using the JAR file.
    When I run this without using the JAR file, here is the command I execute:
    java -cp .;davidp\snmp;filters davidp.snmp.EntMgr
    Where this is executed in a directory that has a "filters" and "davidp\snmp" directory. In this case, because the "filters" directory is in my class path - I can dynamically load my class from it using just its simple name (i.e. "TestTrapFilter").
    So, is there some bug that precludes the "-cp" parameter from working correctly when the "-jar" parameter is used? Is there some other way to initialize or set up the classloader I'm using, so it can find things outside of the JAR file I'm running from? I would hope that it is possible to get the same behavior from my program, no matter if it is run from a JAR file or not.
    Thanks for any assistence!
    Dave

    These posts are pretty old, but this page came up in a google search while I was having the same problem, so I thought I would throw my own (Later found) solution in.
    The -cp and -jar options did not work together for me, but I later learned that they didn't really have to (and you don't have to mess with jar manifest files).
    While on the command line, if you want to set a specific class path and also run a jar, all you need to do is add the jar to whatever extra class path you need to use in the -cp <arg>, and then specify which class you want run from inside the jar.
    IE:
    java -cp <YourSpecialClasspath>: <PathToJar> <ClassToRunInsideOfJar>
    in my case it was like:
    java -cp /home/user/WebRCP.jar:./StandaloneInstaller.jar InstallLoader
    Remember to put a ":" in between the two arguments for the class path (-cp).
    Hope this helps someone in the future,
    -Josh

  • Command line options in executable jar

    Hello,
    On a win32 system I have an executable jar that the user dbl clicks to run.
    What I would like to do is maintain this simple dbl click to run but have command line options passed to the vm. ie I would like the dbl click to invoke
    javaw -Xms60m -Xmx120m -jar myjarfile.jar
    rather than just
    javaw -jar myjarfile.jar
    Can these options be placed in the jar files manifest? If so how? (I can't see how to do it)
    Many thanks
    Mike

    why not use special .jar tool to help you to save much
    of your time?
    Thanks for the idea but it really doesn't answer my question.
    Mike
    [Edited by: jdcforumadmin1 on Jun 24, 2002 1:39 PM]

  • File format for username/password file for -vcusersfile command line option

    In what format do I specify username and password in a file that I can use for
    the -vcusersfile command line option?

    The text file should contain name/password pairs separated by an equal sign. Example:
    myname1=password1
    myname2=password2
    Hope that helps,
    Susan Doan

  • File name as command line option for multiple VM processes

    "-Xloggc:/tmp/gc.log" is the option I'd like to set, but every process will log to that file and even if we don't experience any concurrency issues the data still isn't useful because I can't tell which process did what.
    The island files are cleverly named to include their process number, can I do similar for command line options or will I be restricted to a single JVM?

    Online help (as of LabVIEW 7.0?), Index, Command Line, User-defined arguments - It will show you the following:
    You also can pass LabVIEW-defined or user-defined arguments when you launch LabVIEW from the command line. To pass user-defined arguments in the command line, enter two hyphens (--) surrounded by spaces before the set of user-defined arguments. LabVIEW does not use any arguments after the two hyphens to launch labview.exe. LabVIEW passes the arguments after the two hyphens to the block diagram of the VI you launch. Use the Application:Command Line Arguments property to read the user-defined command-line arguments passed when LabVIEW launches.
    For example, to launch mycool.vi and pass user-defined arguments, use the following command:
    c:\labview\la
    bview.exe c:\coolapp\mycool.vi -- 1000 sine
    On the block diagram of the mycool.vi, use the Application:Command Line Arguments property to read the 1000 and sine arguments you passed and handle the values.
    Enjoy,
    Roy

  • Q. Any command-line options for Digimarc and Elements 7 batch file processing?

    Q. Any command-line options for Digimarc and Elements 7 batch file processing?

    Are you a digimarc subscriber? You would be better off asking them, if so.

  • Command line options / API Support to launch the sequence file

    does teststand support any command line options / API Support to launch the sequence file and also populate the test run status. I want to explore the option of integrating the teststand with QC where I can launch the sequence from QC and results are sent back to QC.
    Thanks in advance,
      -Dilip

    Hi Dilip,
    Here are the command line options for TestStand v4.2.1:
    Command Line Processing
    Command line usage:
       seqedit.exe [<sequence file>]
                   [/goto <location>]
                   [/run <sequence> <sequence file>]
                   [/runEntryPoint <entry point> <sequence file>]
                   [/quit]
                   [/setCurrentDir]
                   [/useExisting]              
                   [<workspace file>]
          <location>:  property object path to the item to display in the file
                   Location examples:
                         TestExec.exe c:\example.seq /goto "Seq[\"MainSequence\"].Main[\"Power On\"]"
                         TestExec.exe c:\example.seq /goto "Seq[\"MainSequence\"].Main[\"ID#:JifH4ODTf0y1z7bJ​ne0G7D\"]"
                         TestExec.exe c:\example.seq /goto "Seq[1].Main[4].TS.LoadOpt"
          <sequence file>:  sequence file to open
          <sequence>:       sequence to run
          <entry point>:    entry point, such as Single Pass or Test UUTs, to run
          <workspace file>: workspace file to open
       You may specify multiple sequence files, sequences, and entry points.
       Quotes are required for arguments that contain a space, such as
       "Test UUTs" and "C:\My Documents\Test Sequence.seq"
    I don't believe you'll get a return status of the executed sequence from the editor on close; but you could design your sequence to write the status to a file and then read that by your QC application.
    -Jack

  • Sending Command Line Arguments to Jar Executable

    Hi All
    I wish to send Command Line Arguments to Jar Executable.
    i.e. before I Jar'd my program, I would do the following
    public class CmdLnArgmntExp {
    public static void main(String[] args) {
    System.out.println("d");
    for (int i = 0; i < args.length; i++)
    System.out.println(args);
    Running the program in Console.
    Java CmdLnArgmntExp arg1 arg2 arg3 arg4Output:
    arg1
    arg2
    arg3
    arg4
    How would I do this to a Jar executable, hope that made sense
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    java -jar executable-jar-file-containing-class-CmdLnArgmntExp.jar arg1 arg2 arg3 arg4

  • Command line option to specify Bridge master cache

    Please allow a bridge command line option to allow the user to select a specific bridge master cache.
    The  motivation is as follows:  I have written a c++ programme to key-word  all of my many thousands of photo projects.  Essentially each project is  in a separate directory on 8 terabytes of networked disk.  Associated  with each directory is a set of key words.  When the appropriate project  is selected, I invoke Bridge to open that directory, possibly with a  specific images as the "starting image" for that project.  Since the  master cache files are split (to accomodate the 500,000 max image count  supported by bridge), it would be excellent if I can pass a reference to  the specific master cache associated with that directory.
    A second value of this option would allow the user to create desk-top short-cuts to invoke bridge using an appropriate cache structure.  For example, the properties of one short cut could specify the cache file for the current daily use of the Bridge to process images in progress.  A second could point the the cache associated with the historical first 400,000 image archived on the network, and a third could invoke bridge pointing to the cache for the next 400,000 image cache - or whatever grouping the user needs to match his workflow when using Bridge as the central focus for various digital assets..
    This type of processing allows the user to conveniently invoke bridge according the the needed work flow when multiple cache systems are required.  In addition, the multiple desk-top shortcuts would minimize the "error" of having bridge pointed, by accident/neglect, to the incorrect cache structure.
    It would also be valuable to allow the user to display the current number of actual image items in a cache system - either as a "view" or "tools" option.  This would allow the user to know when it is time to start a new master cache system. Of course, this can be intependently viewed in windows explorer by the count of files in the 1024 or 256 directories - however maybe the cache structure already "knows" this number instantly.  Other statistics could be interesting as well - possibly the number of directories known to the cache (possibly the same as the count of directories within the 1024 or 256 directories). Possibly the number of files cached by file type (jpg, tif, psd, cr2, nef, etc) would be of interest to some folks - however, such things should be user-selectable since such analysis might be time intensive and maybe of no interest.
    Of course, I do not know if this is consistent with other uses of Bridge - this request is made based upon my use of Bridge as a still photographer and a few videos I have created.
    thank you....
    tony

    I'm going to be technical for a minute, just for the Forum archives...
    The Library file location is stored in your "iTunes Prefs.xml" file in<pre>%APPDATA%Apple ComputeriTunes</pre>.
    Actually, I should say that if you are using a non-default location, there is a key for "iTunes Library Location:1", e.g.:
    <key>iTunes Library Location:1</key>
    <data>
    QwA6AFwARABvAGMAdQBtAGUAbgB0AHMAIABhAG4AZAAgAFMAZQB0AHQAaQBu
    AGcAcwBcAFQAZQByAGkAZABvAG4AXABNAHkAIABEAG8AYwB1AG0AZQBuAHQA
    cwBcAE0AeQAgAE0AdQBzAGkAYwBcAHQAZQBzAHQAbABpAGIAcgBhAHIAeQA=
    </data>
    The "data" is a base64-encoded UTF16-LE string that is the folder containing the "iTunes Library.itl" file and "Album Artwork" folder. In the above case:<pre>C:Documents and SettingsTeridonMy DocumentsMy Music     estlibrary</pre>
    The key/data pair does not exist if you're using the default Library location.
    Similary, there is a key/value pair for "iTunes Library XML Location:1" -- except this part always appears, even if you are using the default location. Also, it is the full path to the file itself, not just the directory containing it. e.g.:<pre>C:Documents and SettingsTeridonMy DocumentsMy Music     estlibraryiTunes Library.xml</pre>
    Since it doesn't appear that double-clicking on the Library file you want to open works, I'm guessing the only way to swap locations is to edit the preferences file -- either directly, or with a script/program. I could probably write such a program in a 1/2 hour or so... I might just do that right now.

  • Split PDF by pages using command line options

    Hi,
    I am after a product to split a PDF file by pages / bookmark using command line options.  It would be good, if the product comes with functionality to call from VB/.NET SDK.
    I googled and came across many products, out of these following looks good.  Has anyone used this.  Please suggest me.
    www.neeviapdf.com
    www.coherentpdf.com
    Thanks
    Sarav

    You are posting in the wrong forum. This forum is for Acrobat Scripting.

  • Javadoc command line options

    I have a custom doclet which generates xml output instead of the default ouput from javadoc.
    I am trying to pass custom command line options to my custom doclet class.
    The following is my javadoc command:
    javadoc -classpath c:\junit\junit3.8.1\junit.jar;C:\j2sdk1.4.1\lib\tools.jar -doclet DocGenerator -dest c:\docgen\temp C:\DocGeneratorTest.java
    When i use the above command i get the following error:
    javadoc: invalid flag: -dest
    I am trying to access the value of dest in my custom doclet.
    Regards
    -rv

    Perhaps the following will help. It explains how to use command-line options
    Any doclet that uses custom options must have a method called
    optionLength(String option) that returns an int. For each custom
    option that you want your doclet to recognize, optionLength must
    return the number of separate pieces or tokens in the option. This page gives an example:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/javadoc/overview.html#options
    -Doug Kramer
    Javadoc team

  • Command-line to combine obj files (.o) into a Static Library (lib.a) file.

    I have a library that I need to compile for Solaris 10 x86 using Sun Studio. I compile the source files to make obj files by issuing the command:
    Bash-3.0# cc -c -D"_UNIX_" *.c
    This compiles every source.c and produces an object.o file. (Nice, & simple.)
    Now, what is the command-line to combine all those object.o files (along with a few other staticlibs.a) and make one archive, lib.a?
    I've done this many times with the gnu - gcc compilers. Is it possible with the Sun Studio Tools? And where is it documented?
    I thought I had this 'licked' when installed SS12u1 and built the 'Welcome' project. But I have searched the "Sun Studio 12: C User's Guide" from top to bottom, and I don't have a 'clue' :-( ...
    Mike <><><>

    Run the command
    man arto get the details of using ar.
    If you create an archive library newly each time (instead of trying to update an existing library), this command will do the job:
    ar -r myarchive.a file1.o file2.o file3.o ... I recommend building the archive freshly each time instead of trying to update an existing archive. You can get unpleasant surprises when trying to update.
    To link an archive into a program, just put the archive name on the linking command line (with a -L option to point to the directory if appropriate). The position of the archive on the command line matters. The linker scans the archive as it processes command-line options in order. It pulls a .o from the archive only if it has already seen a reference to a symbol that is defined in the archive. Therefore, the archive must follow all files and other libraries that reference the contents of the archive. Example:
    Suppose f1.o uses something from archive.a, and all files are in the same directrory. This command will work:
    cc -o myprog main.o f1.o archive.a This command will not work:
    cc -o myprog main.o archive.a f1.o The reference in f1.o will not be satisfied.

  • Running from a command line with a .bat file

    I am running my program through a .bat file.
    The .bat file looks as follows:
    java ../classes/HelloWorld
    The .bat file is in a directory at the same level as classes so to get to the class file to run I specify this path. However, it cannot find the class file unless it is in the same directory as the .bat file. Is there a way around this?

    hi,
    as you could have known from the documentation, the java virtual machine executable 'java' expects a fully qualified class name as parameter, no file path. so 'java ../classes/HelloWorld' is of course completely wrong, it should be 'java HelloWorld' and nothing else. if you want to specify a certain path where the class file is to be found, use the -classpath command line option as in 'java -classpath ../classes/ HelloWorld'.
    sincerely, Michael

  • How to pass command line options?

    I know that command line options contrary to command line data arguments start with a prefix that uniquely identifies them.
    I write an application that will copy files from one folder to another. It should be launched with the syntax as follows:
    c:>java my.app.DirectoryScannerConsole
    c:>scan ?input ?C:/test/in? ?output ?C:/test/out? ?mask ?*test*.xml? ?waitInterval 60000 ? includeSubfolders false ?autoDelete true
    c:>exitSo after launching we have two commands: 'scan' and 'exit'. What should I make in my program to be able to invoke these commands in such a manner?
    Edited by: Exaserge on Nov 8, 2008 10:38 AM
    Edited by: Exaserge on Nov 8, 2008 10:40 AM

    Maybe try using Scanner to read in the line of input, then break the line into an String array, then comparing the Strings in the array.
    Something like...
    public static void main(String args[])
       Scanner in = new Scanner(System.in);
       String line = in.readLine(); //read in an entire line of input
       String words[] = line.split(" "); //split that line wherever there is a space
       while ( !(words[0].equals("exit")) ) //if they haven't typed in exit
          if (words[0].equals("scan")
              if(words[1].equals("-input"))
                 String inputFile = words[2]
              //etc.
          line = in.readLine();
          words = line.split(" ");
    }I haven't tried to compile it or anything, so it may not be syntactically correct, but you should get the idea.
    Edited by: chickenmeister on Nov 8, 2008 1:02 AM

Maybe you are looking for

  • Issue with Read only VO Query bind parameters

    Hi Experts, Working in Jdev 11.1.1.3.0 I am face one issue, probably its very common to all of us, bcoz i to do the same thing in N number of times. Issue: select count(*) as cnt from emp where ((:BindEmpId is NOT NULL AND EMP_ID = :BindEmpId) AND (D

  • Excise duty not picking when we enter basic price in contract

    Hi Friends, When we are creating contract, we have to manually enter basic price after entering basic price system is not picking Excise duties. But we are doing carry out new pricing that system is picking excise duty. So i need solution from all SD

  • I can't open files with Pages

    Im having problems with Pages. when I open the application, I don't see the window that allows me to pick files to open from my computer or the icloud.

  • Re: Printing Problems

    ColorLaserjet 2550. I have vertical lines on printouts right down the screen. Just replaced imaging drum, but drum warning light no longer shows.

  • Transferring pics from macbook pro to iphone

    Hi, I'm trying to send pics from the laptop to the iphone. I read how to get the pics from the phone to the laptop but how do I get pics from the laptop to the iphone?