Make "jar" files true executables: allow to pass in params in manifest!!

Right now a jar file's manifest can have a "main-class" which makes the jar truly executable - you can double-click it. The problem is, if you need environment variables, there is no way to pass them in to your main-class' "args."
So why don't we make it so when the jar's manifest is read, that in addition to "main-class" you can have "main-args"?
That would mean everyone would no longer need to bundle java apps with ".exe" or ".bat" or ".sh" files!!! We could have truly Java applications, that are executables!!!
Just package them in a jar, have a main class and the args for it!!
what does everyone think?

Right now a jar file's manifest can have a
"main-class" which makes the jar truly executable -
you can double-click it. The problem is, if you need
environment variables, there is no way to pass them in
to your main-class' "args."
So why don't we make it so when the jar's manifest is
read, that in addition to "main-class" you can have
"main-args"?
That would mean everyone would no longer need to
bundle java apps with ".exe" or ".bat" or ".sh"
files!!! We could have truly Java applications, that
are executables!!!
Just package them in a jar, have a main class and the
args for it!!
what does everyone think?OK, in reading the conversation I realize you need to be more specific. You are interested in passing parameters to the JVM, not to your application. Is this correct?
If so, I understand what you are looking for. But this is handled by the system properties class. If you have some JVM parameter you need to set from the command line, besides memory and other USER ONLY parameters, they should be set by system properties. If they don't show up in system properties, then you need to request that they do.
A jar file is already a cross platform executable of sorts. Why do you think its not?

Similar Messages

  • How to make Jar files in JBuilder

    I would like to know how to make jar files using JBulider. I have a problem with a project that I am working with in Swing. I have made the project on JBuilder and when I make a jar file it will not run upon clicking.
    Any body with an answer, please help
    Abhi

    It sounds like your Main-Class is not set properly in your manifest. To set your Main-Class, please follow these directions:
    http://java.sun.com/docs/books/tutorial/jar/basics/run.html

  • How to make jar files availabe for deployed EJBs

    Hi,
    I'm interested on how to make jar files availabe for deployed EJBs.
    My EJB is packed in an ear. It uses a util jar. I now just add the jar to the
    classpath, but I think that shouldn't be the way. Is there somthing in the admin
    console to make jars available or do I have to insert it in the ear file? And
    if so, where do I hve to place it?
    Thanks
    Claudia

    Put the util.jar in the ear with your ejb jars - at the same level (i.e. in
    the root) - but do not include them in the manifest.xml.
    Also each ejb jar that refers to util.jar must have util.jar on its internal
    classpath in the manifest.
    "Claudia" <[email protected]> wrote in message
    news:3d537db5$[email protected]..
    >
    Hi,
    I'm interested on how to make jar files availabe for deployed EJBs.
    My EJB is packed in an ear. It uses a util jar. I now just add the jar tothe
    classpath, but I think that shouldn't be the way. Is there somthing in theadmin
    console to make jars available or do I have to insert it in the ear file?And
    if so, where do I hve to place it?
    Thanks
    Claudia

  • Scheduling Jar files to execute

    Hey Everyone!
    Help Please!
    Im needing to schedule one of my jar files to execute late at night,when no one is around! The jar file works perfectly, but when scheduled does not run,I have tried using various schedulers and none of them execute the jar file at the scheduled time, it doesnt even start up the JRE,it just gives an error msg that it could not start!I have tried with various jar files and various schedulers!
    I dont want to use Java's timer, I want to be able to schedule it using something like win98 scheduler!So that my clients can schedule it for anytime they want to,at that level of ease!And I dont want a thread running in the background 24-7!
    Is this a bug in java,or am i missing out on something here???
    Thanks guys!
    Justin

    I schedule all my java *.jar program through a batch file. For example, if you have a program HelloWorld.jar in c:\test directory. I would create a HelloWorld.bat file such as:
    c:
    cd c:\test
    java -jar HelloWorld.jar
    exit
    Then, I will schedule my HelloWorld.bat to run at anytime I like.
    This works for me on all my scheduled java progarms.

  • How to make jar file?

    hi
    i want to make my jar file of my own package name "practise".
    can u help me in making jar file.
    what is the command to make jar file?
    expected name of jar--> runner
    package for which i want to make jar----> practise
    plz help me in this regard.
    i m very greatfull to your precious comments and suggestions.

    hi
    if u r creating first time means...
    jar cf filename.jar *.*
    u want to update jar
    jar uf filename.jar *.*
    extract
    jar xfv filename.jar
    (filename is ur package name)
    do this...
    .

  • How to make jar file for this compilation method ?

    can any one tell me how to make jar file for this compilation
    D:\java\browser\IEInJava>javac -classpath jdic.jar;. IEInJava.java
    D:\java\browser\IEInJava>java -cp jdic.jar;. IEInJava
    *this is a compile code:-*
    D:\java\browser\IEInJava>javac -classpath jdic.jar;. IEInJava.java
    *and this is a run code:-*
    D:\java\browser\IEInJava>java -cp jdic.jar;. IEInJavanow how make JAR file ?

    Assuming IEInJava only uses classes inside the jdic jar, this is one way. D:\java\browser\IEInJava> jar cf yourjar.jar IEInJava.classThen to run it you would use D:\java\browser\IEInJava> java -cp jdic.jar;yourjar.jar IEInJavaAnother way would use the jar manifest file to specify the Main-Class and Class-Path.

  • I want to make jar file

    i want to make jar files with Konversi.class , how to make it , i hope it like exe file any idea?

    Use the jar command to create jar files. The command options are extensive, you should read this tutorial for the details.
    http://java.sun.com/docs/books/tutorial/deployment/jar/index.html
    If you want to be able to click a jarfile on a Windows or Solaris system and have a program start running, you will need (as a minimum) to add tio the manifest file (inside the jar) the parameter Main-Class: <path+classname> This is all explained in the tutorial.

  • How to make .jar files executable by double clicking

    hi,
    I've been trying to make my .jar file created via ANT Tool executable by double clicking it but I'm not being successfull. I looked at the ANT Tool for making manifest.mf and I included most of the attributes listed there and later found that Main-Class attribute is required but its not mentioned in the documentation.
    So, I'll be very greatful to receive any suggestions
    regards,
    Jay

    ya I've been doing things the same way mentioned there but it isn't working. here is the code for it:
    //All the .class files are in the build directory and the class files are under the package org.home.proj.
    <!-- For making .jar files -->
    <target name="jar" depends="compile" description="Makes CyberStation.jar from the CyberStation code.">
        <mkdir dir="${bin}" />
        <jar jarfile="${bin}/CyberStation.jar" basedir="${build}">
          <exclude name="**/run.bat" />
            <manifest>
           <attribute name="Buily-By" value="${user.name}" />
           <attribute name="Main-Class" value="org.home.proj.CyberSoft" />
             <section name="org/home/proj/CyberSoft.class">
               <attribute name="Sealed" value="false" />
             </section>
         </manifest>
        </jar>
      </target>It show the error: Could not find the main class. The program will exit.
    regards,
    Jay

  • Double click on JAR file to execute it.... How???

    Hello,
    I wrote a standalone java application, and im wondering how to put a shortcut on my desktop to run the application without having to go into the command prompt to type "java -jar MyProgram.jar".
    I want to be able to just double click on it and have it run. Is there a way to do this?

    Here is how I did it:
    Just install the JDK/JRE and then make a shortcut to the jar file you want to execute. When you install the jre jar's are registered and all you need do is double click them. I've done this in windows 95, 98, Me, NT, and Win2000.

  • Can we make jar file for simple j2se application

    Hi..Can we make a jar file for simple j2se application so that it can be executed on any system like .exe file...

    Read the JAR files section in Sun's Java tutorial.

  • How can I make .jar files for applications?

    My jar program creates jar files but won't open the program when I double click them. I use the command:
    jar cvf *.jar filenames
    The jar file is created but won't execute. Can anyone tell me what i am doing wrong?
    Thanks
    Jiby

    Hello !
    Well, I had the same problem a week or two ago !
    First, in your *.java, don't use any package...I mean, don't do a package of your program (I guess there is a way to make it work with, but it would need a little bit more work...).
    Then, with the jar tools, use the command
    -jar cf jar_that_you_want_to_create.jar class-that_you_include_in_your_jar.class
    With that, a jar will be created, and when you will try to "run" it, it will say that it can not find the main class...
    You need a Manifest !
    Create a text file MyManifest.text, and write that in your text file :
    Main-Class: classname
    follow the same as i wrote above. leave a blank after colon and a blank line after the first line like above.
    then, well, use tha jar tool again:
    -jar umf MyManifest.txt jar-file-you-created.jar
    To "run" it, double click on it, or use the java tool:
    java -jar jar_you_created.jar
    Thanks to Phani, who helped me with that !!
    Splitsch

  • Jar file not executing on double-click

    Hello,
    I have a .jar file that I would really like to execute using a double-click in win xp.
    I can execute the jar file witha java -jar command on the command prompt and the program runs but when double-clicking i get the error: cannot find the main class: program will exit
    I had win rar installed on my computer which changed itself to the default app to open jar files.
    So this is what I've tried
    I tried modifying the registry command to run java -jar, javaw -jar but they don't work.
    I have created several manifest.mf files with this in them
    Manifest-Version: 1.0
    Created-By: 1.4.2_07 (Sun Microsystems Inc.)
    Main-Class: MyClass
    I know that a carraige return needs to be at the end though I don't know really how to check for it (I assume its there because I have a few extra lines after the last text peice). I've read through some other threads but nothing seems to work. It's getting really annoying always having to go through the runline. Thanks for the help.

    I don't understand why Netbeans has such a hard time creating working jar's for applications. This is the second time I've written an application that just will not work when trying to execute using the jar. The last time this happened I used Eclipse and imported everything (including the layout) and Eclipse got it working the first time.
    This time, I thought I'd go back to Netbeans since they released a newer version 4.0 (I haven't gone to 4.1 yet). Apparently nothing has changed as my application, once again will not run from the jar. What's the deal with Netbeans?
    I think I'll, once again bring my project into Eclipse and have that make the jar.
    Kurt

  • How to make jar files at runtime in a server application

    I am using Jung API and i need to load the class files in this JAR file for my application at runtime.
    I am using an applet which uses this API which is loaded with the help of a Servlet.
    The code is getting compiled but the JAR files and associated classes are not available at the runtime
    How to make themk avalable.
    I have tried various options like placing jar files in
    WEB-INF/lib
    $Catlina_Home/commons/lib
    But it is not working can anyone help me it is of high urgency to me
    How to make that classes in the JAR file available to my applet at runtime

    SuperJavaHello wrote:
    How to make that classes in the JAR file available to my applet at runtimeAhh! The runtime is an appler! The applet is on the Client, and the Client does not have access to the Server's classpath. You need to un-pack the JAR, then re-pack the classes into the JAR used to pack your Applet, the one that you are using as the code source in the applet tag.

  • Required jar files to execute WLSTInterpreter.execfile

    Hi,
      I am trying to automate Domain creation and deployment of application via script file. I have written the commands in a file called createDomain.py. I would like to execute this script file through java code. What are all the jar files required to be in class path to execute this script. I have included initially weblogic.jar file and later got one another after another while including the required jar files. Looks like there are too many jar files to be included in class path which i am not sure. Is there any simple way of executing this script file from java code.
    Below is the code to execute the script file:
    WLSTInterpreter interpreter = new WLSTInterpreter();
    interpreter.execfile("/home/user0/createMNDomain90.py");
    Another question is whats the best way to automate execution of this file.

    if you execute the setWLSEnv.sh you can see the CLASSPATH settings, for Example:
    [oracle@vSLLGM132 ~]$ source setWLSEnv.sh
    CLASSPATH=/opt/oracle/product/Middleware/patch_wls1035/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/Middleware/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/JAVA/jdk/lib/tools.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic_sp.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic.jar:/opt/oracle/product/Middleware/modules/features/weblogic.server.modules_10.3.5.0.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/webservices.jar:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/opt/oracle/product/Middleware/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/opt/oracle/product/Middleware/patch_wls1035/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/Middleware/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/JAVA/jdk/lib/tools.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic_sp.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic.jar:/opt/oracle/product/Middleware/modules/features/weblogic.server.modules_10.3.5.0.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/webservices.jar:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/opt/oracle/product/Middleware/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/opt/oracle/product/Middleware/patch_wls1035/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/Middleware/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/JAVA/jdk/lib/tools.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic_sp.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic.jar:/opt/oracle/product/Middleware/modules/features/weblogic.server.modules_10.3.5.0.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/webservices.jar:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/opt/oracle/product/Middleware/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:/opt/oracle/product/Middleware/patch_wls1035/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/Middleware/patch_ocp360/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/opt/oracle/product/JAVA/jdk/lib/tools.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic_sp.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/weblogic.jar:/opt/oracle/product/Middleware/modules/features/weblogic.server.modules_10.3.5.0.jar:/opt/oracle/product/Middleware/wlserver_10.3/server/lib/webservices.jar:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/lib/ant-all.jar:/opt/oracle/product/Middleware/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar:
    PATH=/opt/oracle/product/Middleware/wlserver_10.3/server/bin:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/bin:/opt/oracle/product/JAVA/jdk/jre/bin:/opt/oracle/product/JAVA/jdk/bin:/opt/oracle/product/Middleware/wlserver_10.3/server/bin:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/bin:/opt/oracle/product/JAVA/jdk/jre/bin:/opt/oracle/product/JAVA/jdk/bin:/opt/oracle/product/11.2.0/dbhome_se/bin:/opt/oracle/product/11.2.0/dbhome_se/OPatch:/opt/oracle/product/Middleware/wlserver_10.3/server/bin:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/bin:/opt/oracle/product/JAVA/jdk/jre/bin:/opt/oracle/product/JAVA/jdk/bin:/opt/oracle/product/Middleware/wlserver_10.3/server/bin:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/bin:/opt/oracle/product/JAVA/jdk/jre/bin:/opt/oracle/product/JAVA/jdk/bin:/opt/oracle/product/Middleware/wlserver_10.3/server/bin:/opt/oracle/product/Middleware/modules/org.apache.ant_1.7.1/bin:/opt/oracle/product/JAVA/jdk/jre/bin:/opt/oracle/product/JAVA/jdk/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/oracle/bin:/opt/oracle/bin
    You can copy and paste the CLASSPATH to your program.

  • ...Simplest way to make Jar Files...

    I know there have been numerous questions about jar files and that this has probably been answered before. I am using Forte to develop a program. The program runs fine in Forte, and I used the jar packager to create a jar file. When I double click this file, nothing happens though. I can execute other jar files I have downloaded from the net, but for some reason the ones I create don't work. What is the simplest way to package the classes into a jar file so that I can run my program when I double click it?

    I don't know about double-clicking it to run - that involves making a file association (in Windows) to associate a program with a file type - although I assume you've already done this if you doubleclick others and they run.
    In the case with your own jars it sounds like you need to add a manifest file with the 'Main-class' attribute set to the name of the class that you want to run from the jar.
    eg
    Main-class: YourPackage.YourClass
    The manifest.mf needs to be in a meta-inf dir inside your jar.
    If you open your other jars that do work you will see an example of the manifest.mf file, and the 'Main-class' attribute.
    Also - check in the jdk docs in the tools section - this should tell you all you need to know about the 'jar' tool.
    Hope this helps,
    Kevin Hooke

Maybe you are looking for