A few questions about executable Jar files

Hi,
I have to make an a tutorial system and was going to make it using applets embedded in webpages. This approach causes certain limitations so decided to make it using JPanels that open up as windows on the users computer.
I intend on compressing all the files (java, images, sound etc) within a Jar file and would like a few questions answering.
1. How would I make an executable Jar file that when clicked on will load the program on the users computer. Is there some software to do it for me or do I have to do it from the command prompt?
2. Is using a Jar file the best approach or is there a better way to get my java program to run on other peoples pc's
3. If I create an executable Jar file on windows xp, will it run on a Linux machine?
Cheers

1. How would I make an executable Jar file that when clicked on will load the program on the users computer. Is there some software to do it for me or do I have to do it from the command prompt?The SDK contains all the tools you need. Use the jar command. To make your jar executable, include a manifest file that references your main class.
2. Is using a Jar file the best approach or is there a better way to get my java program to run on other peoples pc'sA jar will work just fine.
3. If I create an executable Jar file on windows xp, will it run on a Linux machine?Yes.

Similar Messages

  • Question about Executable JAR Files

    Is it possible to make an executable JAR file that has all of the *.class files, all of the *.jar archives used, etc. packaged into one file that doesn't need these external files within the same directory? I've been having a ton of trouble finding the answer to this. (If it's blatantly obvious, please forgive me.)

    Hello,
    I went through the same thing recently. Here is a piece of the build file I use:
    <project name="MyProj" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="${build.dir}/classes"/>
        <property name="jar.dir"     value="${build.dir}/jar"/>
        <property name="main-class"  value="MyProj.Main"/>
        <property name="lib.dir"     value="lib"/>
        <path id="classpath">
            <fileset dir="${lib.dir}" includes="**/*.jar"/>
        </path>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
              <zipfileset src="lib/commons-codec-1.3.jar"/>
              <zipfileset src="lib/commons-fileupload-1.1.1.jar"/>
              <zipfileset src="lib/commons-httpclient-3.0.1.jar"/>
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="main" depends="clean,run"/>
    </project>Note the <zipfileset> tags that contain the .jars.
    There are, however, many good reasons to not do this. Some were already mentioned, another is in the case of update external libraries, you might not want to rebuild your whole project, replacing a jar may be easier.
    Good luck,
    -Sam

  • A few questions about signing JARs for Web start

    I'm still a bit new to all this, so just want to clear a few things up.
    I'm currently trying to publish an application using Web start, so i know I have to sign all the JARs, as it needs to do some writing to the hard drive.
    1. I have my main JAR file, and then two "third party" JAR files in the /lib subfolder, I take it I need to sign those two as well, does it matter that I don't have the .class file for those two, as I didn't write them?
    2. I'm running the JARSIGNER program with exactly the same command line apart from the filename of the .jar file, is that correct? or do I need a different certificate for each .jar file?
    Just can't seem to get all three signed, Web start says one different one isn't signed each time I try it out.
    3. When signing, does it add something to the end of the JAR file itself? as I can't see any extra files created.

    Signing adds entries in the mainifest, not in the main file list in the jar file.
    You can sign third party jar files, but it is not advisable. An alternative is to put third party jars in a seperate extension jnlp file, if they need all-permissions, you can get the third party jars already signed by whoever supplied them. If not, you do not need to request all-permissions in the extension jnlp file, and that part of the code will be run in the secure sandbox.
    /Andy

  • Three questions about signed jar file and applet

    I use three signed jar file. Each of them signed by different certificate. First of JARs contain applet class. When I start applet from html page I see message &#8220;This applet was signed by&#8230;&#8230; but Java cannot verify it&#8230; Do you trust&#8230;?&#8221;. All times I press &#8220;Yes I trust&#8221; and after this questions applet stop to work end exit. If I use only one certificate for signing of three JARs then applet continue to work after question. 1) What should I do to fix this bug? 2) Is it any method to check from applet that user press Trust button? Is it any method to emulate work of SecurityManager to check that Certificate object is trusted (I want do call some method check(Certificate) and if certificate is not trusted I want to see message with question: &#8220;Do you want to trust this certificate&#8221; and so on)?

    Hello Jarman,
    1. If I have a signed jar file, then as long as the
    certificate is recognised as trusted that applet can
    run as a fully trusted application on the client
    machine. So I should not have to add lines such as
    permission java.lang.RuntimePermission
    "readFileDescriptor", "read" ;
    permission java.lang.RuntimePermission
    "writeFileDescriptor", "write" ;
    to my java.policy file. true/false ?true
    2. If I am running a signed jar file in the Java
    plugin then I do not need to have a verisign or thawte
    certificate (however to allow my certificate to be
    accepted I do have to import it into the cacerts file
    on the client machine). True/false?true
    3. Following on from question 2, if I want to be able
    to run an applet on a client machine, without messing
    around with ANY files on those machines, I need a
    verisign or thawte certificate. True/false?true
    4. (And finally) Apart from a security exception
    saying that I need to add one of the lines like those
    of question 1, is there any way I can get other debug
    information as to why the signed jar file is not being
    recognised as signed?No. This could be a problem of importing your certifcate into the wrong place.
    The information on the following link is a little bit dated but it helped me to successfully install a testcertificate and sign an applet with it.
    http://www.suitable.com/Doc_CodeSigning.shtml

  • Qusetion about Executable JAR files

    I use the Eclipse IDE on Mac OS X Leopard. I was just wondering, if I create a JAR file on mac, can I send it to a Windows user and they can run it perfectly (Swing application)? Or do I need to export it differently to get it to work on windows. I just want all users to be able to use it.

    Encephalopathic wrote:
    briyu wrote:
    I use the Eclipse IDE on Mac OS X Leopard. I was just wondering, if I create a JAR file on mac, can I send it to a Windows user and they can run it perfectly (Swing application)?It should work fine "out of the box". If it's important though, why not test it out? Have a buddy with a Windows computer test your app. ...(As usual) Great idea.
    Swing apps. can be launched using [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp] . If you could provide a sand-boxed(1) version of your application, I am confident(2) people will be willing to give it a quick test. I cannot confirm anything about Windows, but would be willing to give it a try under Ubuntu Linux.
    (1) If the app. uses files, it is handy to test if File paths are being formed correctly, but that would require an 'all-permissions' version that is not sand-boxed. Less people are willing to test code that is allowed to do 'anything' on their system.
    (2) See [This 'new Plug-In' applet working?|http://forums.sun.com/thread.jspa?threadID=5396891] for an example.
    Edit 1:
    BTW - Welcome to the Sun forums.
    + minor text edits.
    Edited by: AndrewThompson64 on Jul 12, 2009 2:37 AM

  • Few Questions About Backing Up Files

    Okay, I'm pretty new to this, and have checked the support pages, but I do have some questions about backing up my files.
    I'm running out of room on my computer's hard drive, and am wondering if burning the library to CDs will allow me to quickly restore my library on my computer when I sync my iPod.
    I know that when an iPod syncs with a comp, it will lose any songs that aren't on the library list. (If I deleted some songs to free up room, I'd lose those songs on my iPod when I synced it up.) Is there a way to prevent that from happening? Some way to save a headache continuously restoring my iPod's library every time I want to add a new song or recharge it?
    I'm on Windows XP, if that matters.

    Best and easiest solution is to buy an external hard drive. Then simply drag and drop your iTunes folder from your internal onto the external and copy the entire library.
    Patrick

  • Quick Question **PLEASE HELP** .jar file?

    Hey everyone, im pretty new to the java scene but I have a really quick question that hopefully someone can help me with.
    I'm really interested in making a .jar file out of my code. And basically I just want to make one. but i understand there are certain things like main class's, etc. that need to be made in order to make a .jar file.
    So basically Say I opened up a new project in blueJ. I made 1 new class called "main." Inside of it I had nothing for conductors and no variables declaired untill the bottom part where i write my code.
    say i write...
    System.out.println("hello");
    and that is it.
    What steps from there do i do to make a jar file and have it be able to be executed and SEE the "hello" printed somewhere NOT in blueJ??
    (I understand there is something about a "static" method? Im not really sure but if somoene could enlighten me on how to make a .jar file that would be great.)
    Thanks a lot everyone!
    Tom

    I don't know anything about BlueJ, but this section of Sun's tutorial explains how to
    write a program that outputs a single line of text to the console:
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
    Deploying an application as an executable .jar file is covered here:
    http://java.sun.com/docs/books/tutorial/deployment/jar/index.html
    The first two sections - "Using JAR Files: The Basics" and "Working with Manifest
    Files: The Basics" - contain the information you need to understand this process.

  • Associating executable Jar files w/ appropriate program

    Hi, I'm kinda new to java but this question is more OS related I think. I made a GUI program that reads / writes files and does some other stuff, I compiled it, then made it into an Executable JAR file. I put the file on my dektop w/ the required resource file (contains the read files) and then I double-click it and lo and behold Win-Ace(R) popps up. I right-clicked on the executable jar file, associated it with JAVAW, double-clicked again and it worked. So i guess my question is, is there a way that it will automatically associate itself with the right program so when I give this program to other people, they won't have to associate it the same way?
    Anyhelp would be greatly appriciated!

    No, becourse even if java could do that it would make sence becourse to run the jar it must be associated with javaw.
    But you could try to create a .reg file (registry file) that associate jar with javaw, when somebody runs the reg file it associate jar with javaw.
    But I think you should make different reg files for different windows versions (not sure about that).
    I don't have experience with how to write reg files but you just google.
    But I should try it out on your own windows, you could install windows on another partion and try it out on that one (first make a image with norton gost or something so if something goes wrong you can fastly get back to the old state).
    But you can also export your registry to a file so you can put the old registry back if somethings goes wrong.
    Use these tips on you own risk!!!

  • Why -jar option used to install a software which is in executable jar file?

    Hi all,
    i have a query, i have a generic installer which is used to install the oracle weblogic 10.3 software in unix platform(i.e., which is in .jar extension) which is executable jar file.
    To install this software which have to use -jar option to install
    java -jar net_server<version>_generic.jar
    my question that why we use -jar option to install or to extract the software
    can any one clarify my doubt...
    thanks in advance
    abhi
    Edited by: sumanth_abhi on Jan 27, 2009 11:50 PM

    According to the Jar Guide (http://java.sun.com/j2se/1.4.2/docs/guide/jar/jarGuide.html)
    Executable Jar Files
    On Microsoft Windows systems, the Java 2 Runtime Environment's installation program will register a default association for Jar files so that double-clicking a Jar file on the desktop will automatically run it with javaw -jar. Dependent extensions bundled with the application will also be loaded automatically. This feature makes the end-user runtime environment easier to use on Microsoft Windows systems.
    The Solaris 2.6 kernel has already been extended to recognize the special "magic" number that identifies a Jar file, and to invoke java -jar on such a Jar file as if it were a native Solaris executable. A application packaged in a Jar file can thus be executed directly from the command line or by clicking an icon on the CDE desktop.
    Despite that every JAR file can be executed as a program if and only if the META-INF/Manifest.mf contains the Main-Class tag. This done through java -jar jarfile.jar
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Few questions about upgrading database

    Hi everyone,
    greetings of the day
    I have few questions about the upgrading database,
    In export and import mode
    1.can we have new name for the target database,
    2.I think we need to create tablespaces ,do we need to create users as well
    3.If we are upgrading from 9i to 10g database ,any activity to be perfromed other than creating a new sysaux tablespace
    4.How come we get consistent export
    In DBUA mode ( in the same machine only)
    1.Do we need shutdown / startup restrict the database
    2.How can we move the files to the new location
    3.Can we change db_name of the database
    4.Can we use the old database as well
    In manual upgration using catupgrd scripts
    1.Can we rename the db_name
    2.can we use old database as well
    3.how to move the database files to the new location
    4.can we perform this kind of upgrade on a different server
    5.when we startup upgrade in the new home ,how it identifies the old database in-order to upgrade the old one
    Thanks

    udayjampani wrote:
    Hi everyone,
    greetings of the day
    Pl post details of source and target database versions, along with your OS details.
    I have few questions about the upgrading database,
    In export and import mode
    1.can we have new name for the target database,Yes.
    2.I think we need to create tablespaces ,do we need to create users as wellYou can create users, but it is not necessary. You need to pre-create tablespaces only if their characteristics/locations on the target are different than on the source.
    3.If we are upgrading from 9i to 10g database ,any activity to be perfromed other than thisNot that I am aware of - see the steps in the Upgrade Guide - http://docs.oracle.com/cd/B19306_01/server.102/b14238/expimp.htm
    4.How come we get consistent export wetherEnsure the database is started in restricted mode, so users will not be able to access the database during the export.
    >
    In DBUA mode ( in the same machine only)
    1.Do we need shutdown / startup restrict the databaseNo - DBUA will do this automatically for you.
    2.How can we move the files to the new locationYou can after the upgrade move the datafiles to wherever you want - use the ALTER DATABASE RENAME DATAFILE (http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_1004.htm#i2082829) command.
    3.Can we change db_name of the databaseI do not believe this is possible with DBUA.
    4.Can we use the old database as wellNo - the database will be upgraded by DBUA - there is no "old" database.
    >
    >
    In manual upgration using catupgrd scripts
    1.Can we rename the db_nameYes.
    2.can we use old database as wellNo - the scripts will upgrade the database - there is no "old" database.
    3.how to move the database files to the new locationSee above.
    4.can we perform this kind of upgrade on a different serverPl elaborate on what you mean by this. You can copy the existing database to a different server (assuming compatible OS) and upgrade it there.
    >
    >
    ThanksHTH
    Srini

  • EBS 12.1.3: a few questions about cloning

    Hi,
    We have EBS 12.1.3 on AIX 7.1.
    A few questions about cloning from shared application tier environment to non-shared application tier environment. We have been following "Cloning Oracle Applications Release 12 with Rapid Clone [ID 406982.1]"
    Source environment (shared app tier):
    - Two active application nodes and LB
    - One active database and one passive database setup with Oracle Data Guard.
    - SSL termination at the load balancer
    - PCP implemented
    Target environment (non-shared app tier):
    - One active application node
    - One active database node
    - No SSL
    - No PCP
    After the cloning was completed we noticed the following problems in the target system:
    1) Home page cannot be accessed as application tier $CONTEXT_FILE still contains "https" and ssl termination settings.
    Workaround:
    Modify (with text editor) Application Tier $CONTEXT_FILE as follows.
    <webentryurlprotocol oa_var="s_webentryurlprotocol" customized="yes">http</webentryurlprotocol>
    <sslterminator oa_var="s_enable_sslterminator">#</sslterminator>
    <login_page oa_var="s_login_page" customized="yes">http://myhost.mydomain.com:8000/OA_HTML/AppsLogin</login_page>
    <externURL oa_var="s_external_url" customized="yes">http://myhost.mydomain.com:8000</externURL>
    Run AutoConfig and start application tier.
    Is there a better and supported solution for this?
    2) Concurrent managers do not work correctly as they have still old node names (used in PCP in the source system). Workaround used:
    1. Logon to EBS web GUI and remove all nodes from all concurrent managers.
    2. Shutdown application tier. Verify that all concurrent managers have been shutdown. If not, kill the processes manually
    3. As apps user run cmclean.sql
    4. Restart application tier
    Is there a better solution for this?
    3) Database changes from ARCHIVELOG mode to nonarchivelog mode in the target system. Is there anyway to prevent this?
    4) Also, we would like to perform a full clone (app + db tiers) from production without shutting down the application. Is this possible? What would be the best documents to describe this? In Production, we have Oracle Data Guard setup with physical standby as per "Oracle Tech Note: Business Continuity for Oracle E-Business Release 12 Using Oracle 11g Physical Standby Database [ID 1070033.1]". This can be used when performing a hot clone for the database, right? What about the application tier? Steps described in 406982.1 include running AutoConfig in which application tier should be down. Does the application need to be down when running "Maintain Snapshot Information"?
    5) One final question (not related to cloning). Oracle Enterprise Manager console webUI has recently stopped working in IE8. E.g. https://myhost.mydomain.com:5501/em gives "Page cannot be displayed". This was working correctly last week. In Firefox, the same link is working fine. Any ideas how to fix this?
    Thanks for your answers in advance.
    BR,
    TH

    1) Home page cannot be accessed as application tier $CONTEXT_FILE still contains "https" and ssl termination settings.
    Workaround:
    Modify (with text editor) Application Tier $CONTEXT_FILE as follows.
    <webentryurlprotocol oa_var="s_webentryurlprotocol" customized="yes">http</webentryurlprotocol>
    <sslterminator oa_var="s_enable_sslterminator">#</sslterminator>
    <login_page oa_var="s_login_page" customized="yes">http://myhost.mydomain.com:8000/OA_HTML/AppsLogin</login_page>
    <externURL oa_var="s_external_url" customized="yes">http://myhost.mydomain.com:8000</externURL>
    Run AutoConfig and start application tier.
    Is there a better and supported solution for this?No, you need to edit the context file manually and run AutoConfig.
    2) Concurrent managers do not work correctly as they have still old node names (used in PCP in the source system). Workaround used:
    1. Logon to EBS web GUI and remove all nodes from all concurrent managers.
    2. Shutdown application tier. Verify that all concurrent managers have been shutdown. If not, kill the processes manually
    3. As apps user run cmclean.sql
    4. Restart application tier
    Is there a better solution for this?You are following the best approach. You could update the node details from the backend if you want.
    3) Database changes from ARCHIVELOG mode to nonarchivelog mode in the target system. Is there anyway to prevent this?By default, Rapid Clone will create the target database in noarchivelog mode.
    4) Also, we would like to perform a full clone (app + db tiers) from production without shutting down the application. Is this possible? What would be the best documents to describe this? In Production, we have Oracle Data Guard setup with physical standby as per "Oracle Tech Note: Business Continuity for Oracle E-Business Release 12 Using Oracle 11g Physical Standby Database [ID 1070033.1]". This can be used when performing a hot clone for the database, right? Correct.
    What about the application tier? Steps described in 406982.1 include running AutoConfig in which application tier should be down. Does the application need to be down when running "Maintain Snapshot Information"?You can copy the application tier node files while the application is up. And, you do not need to shutdown the application to run "Maintain Snapshot Information".
    5) One final question (not related to cloning). Oracle Enterprise Manager console webUI has recently stopped working in IE8. E.g. https://myhost.mydomain.com:5501/em gives "Page cannot be displayed". This was working correctly last week. In Firefox, the same link is working fine. Any ideas how to fix this?
    If it is working from one browser, then it should not be an EM issue. Have you tried from a different client and see if this works? Have you changed any setting in your IE browser? Please make sure you add the EM URL to the trusted sites list.
    Thanks,
    Hussein

  • How can I add image files to a executable jar file ?

    Could you tell me how can I add image files to executable jar file ?
    package structure:
    ../com/Main.class
    ../images/..

    Please don't cross post, and read this
    http://forum.java.sun.com/thread.jsp?forum=31&thread=271751
    I've answered the question in the New To Java thread.

  • Add classpath in an executable jar file

    an executable jar file contains a manifest file with entry main-class: MyApplicationClass.
    if we double click the jar file on Windows OS, main class is loaded.
    my question is:
    if classes in he jar file use classpaths which are not default, how to add those classpaths into manifest file to tell classes to use those classpaths?
    it is similar to command line:
    java -classpath c;\mypackage; .......; MyApplicationClass

    Thanks, i will try soon.
    here is another Q.
    if i need to add tools.jar (JDK lib) as classpath in manifest file, it is as following in my PC
    d:\install\java\jdk14101\lib\tools.jar.
    but my customers install JDK in different path (should be considered as unknown), how to add it as entry Class-path for all customers?

  • Why i can't execute jar files

    Greetings
    I read that jar files are executable unpon clicking them, but with me it do nothing.
    right now i'm using the command prompt to decompress jar files
    jar -xf jarfile.jar
    i have windows xp professional with j2sdk1.4.1

    You can execute JAR files by double-clicking them if the JAR files have an appropriate manifest and your file associations are set correctly (i.e. make sure you open JAR files with JAVAW.EXE). You can learn more about the manifest here:
    http://java.sun.com/docs/books/tutorial/jar/basics/manifest.html

  • Error trying to run an executable Jar file

    Hi,
    I know a million people have asked this before. In the past 5 hours I have waded thru a dozen questions-answers-FAQs that were no help. So if anyone is willing to help a stupid person her is my problem:
    I developed a java program using the eclipse ide and it runs fine from within that ide.
    I packaged it into a Jar file, created a manifest file per the instructions.
    But when I double click on the jar file I get the following error from the Java Virtual Machine Loader;
    "Could not find main class. Program will exit."
    My Manifest file has the following text:
    Manifest-Version: 1.0
    Class-Path: swt.jar
    Main-Class: .graphicalUserInterface.AppStandAlone
    <blank line>
    the class AppStandAlone has the method "public static void main(String[] args) "
    it is in a package called "graphicalUserInterface".
    Any help anyone can give me would be greatly appreciated.

    Another 3 hours spent trying to run this java application in a Jar file.
    I identified that I did not have all class paths specified. So I tried to enter them in the "Class-Path:" line of the manifest file. But, according to the java tutorial, the syntax in a manifest file for classpaths is a space SEPARATING each path name. I have a space IN the path name and java is not understanding the paths correctly. For instance, I have a classpath c:\Progran Files\Java\etc... and java interprets this to be a classpath c:\Progran with Files\Java\etc as the program I want to run.
    I tried enclosing the paths in double quotes. Didn't work
    I tried enclosing the paths in single quotes. Didn't work
    I tried using a semicolon as a separator with double quotes. Didn't work
    I tried using a semicolon as a separator with single quotes. Didn't work
    I tried using a semicolon as a separator with no quotes. Didn't work
    I removed the "Class-Path:" line from the manifest and tried adding -cp param to the java command. Example:
    java -cp %classpath% -jar myapp.jar
    I tried all the variations above in the -cp param. None of them worked.
    The only thing that works is if I move executable jar file to the same directory as the required libraries. Then I specify a "Class-Path:" line with no spaces in the path names. Obviously this is not a permanent solution.
    If anyone else has the patience to help me I would really appreciate it.

Maybe you are looking for