Extract contents of a .Jar file or executable jar file

I have an executable Jar file.. Is there anyway that I can see the contents of this file.. the code in it..
I have read some tutorials on how to extract .jar files but the question is where do i execute these commands.. is it on the command window or somewhere else.
Can anyone help me plz????????

but the question is where do i execute
these commands.. is it on the command window or
somewhere else.
If you're using windows OS, you can do execute the
command in dos promt
and if you're using linux, you execute it in the
Terminal/Console or double click on the file name in
the
Knoqueror, you can see the contents.Konqueror file manager,you can see the contents.

Similar Messages

  • Extracting files from executable jars at runtime

    I'm still pretty new to Java, and I'm trying to find out how (if it's possible) to access files inside jars at runtime. More to the point, I am trying to make a help file for my application, stored as a .txt file. Currently I have the text file in the same directory as the source code, and I am bundling the source directory into an executable jar. However, when the jar is executed, it cannot find the file. There's got to be some mechanism for automatically loading files that are in the source directory. This issue is confused by the fact that I am using Windows XP, and so the default home directory to execute from is the My Programs directory. Any help would be appreciated!

    [url http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html]Class.[url http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getResourceAsStream(java.lang.String)]getResourceAsStream(java.lang.String) is what ye want.
    InputStream is = class.getResourceAsStream("myhelpfile.txt"); will get a file in the folder as your class file.
    InputStream is = class.getResourceAsStream("/myhelpfile.txt"); will get a file in the root of the jar.

  • Differences between Debug .exe file and Execute .exe file

    We are very confused by the following problem when we are using
    LabWindows/CVI to develop our application:
    Our program is for retrieving data from real time and process the data to
    get the statistic results. If we run the program using "Run >> Debug
    OurProject.exe", it runs very well. However, if we run this same program
    in
    two steps: first using " Build >> Create Debugable Executable" menu, then
    using " Run >> Execute OurProject.exe", it can not run and outputs very
    different results. How come does this happen? What's the difference between
    these two kinds of running a program? Please help!

    it might be that there are some variables not initialized. the development environment automatically initializes all variables. an executable program does not.

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • 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.

  • Executable Jar Trouble

    Hello everyone,
    I am creating an executable jar with this command:
    jar cmf CarmaFrame.mf CarmaNew.jar *.*
    The contents of the manifest file (CarmaFrame.mf ) are:
    Manifest-Version: 1.0
    Class-Path: j.jar
    Main-Class: CarmaFrame.class
    This creates an executable jar in the directory that contains all of the files. It executes fine when double clicked in windows xp.
    If I move the newly created jar file to my desktop and try to double click it, I get this error:
    could not find the main class. program will exit.
    None of my java files are using packages. Any ideas on why I am having this problem?
    BTW, the j.jar file is a dependent jar file that does show it is in the CarmaNew.jar file when using the command:
    jar tf CarmaNew.jar
    Thanks,
    Brandon

    Packaging a jar within an executable jar:
    http://forum.java.sun.com/thread.jsp?forum=22&thread=405160&tstart=0
    http://forum.java.sun.com/thread.jsp?forum=22&thread=505248&tstart=0&trange=15
    http://forum.java.sun.com/thread.jsp?forum=4&thread=432114&tstart=0

  • Executable jar  //double click

    These are my problems:
    - I'm able to execute the jar file with the line command: java -jar Myfile.jar
    but not double cliking on it. Why ? What should I do ?
    SOME DOUBTS LESS IMPORTANT:
    -I tried the command: jar cmf manifest.txt Myjarfile.jar *.*
    Manifest is added to the archive but it doesn't work. Why?
    Instead it works if i add it with the command: jar umf manifest.txt Myjarfile.jar
    - If I try to insert a manifest.txt file with more than one line happen this strange thing:
    With a file like this the command works:
    Class-Path: AbsoluteLayout.jar
    Main-Class: Mymainclass
    With a file like this it doesn't add the second line:
    Main-Class: Mymainclass
    Class-Path: AbsoluteLayout.jar
    Why ?
    Thankyou for your help.

    it may help you..
    a tool named JavaJar(written by java) can compress and decompress jar,war, ear and.zip...
    it can deal with manifest file and executable .jar file .specially.
    may download from http://www.qwerks.com/download/4114/JavaJar.zip
    the tool is very verygood tool.
    but the homepage(www.pivotonic.com) of JavaJar cannot be accessed.
    it is funny.
    good lucky.

  • Any Possibility To Extract Contents of a JAR File

    Is there Any Possibility To Extract Contents of a JAR File . i.e class files with proper names.
    Thnks

    Well, than it's to bad. There is no way to get the original names back. It's supposed to be that way, you know ;)

  • Unable to execute JAR files

    I am unable to execute jar files and applets. Also, the Java Web Start and the Java Plugin Control Panel will not load. I have unloaded the JRE and installed other versions. To date I have loaded and unloaded the following:
    1.4.1
    1.4.2_01, _02, _04
    1.4.2_04 SDK
    But no change in the outcome.
    The javaw application starts but does not load the jar file.
    The applets and jar files run fine on other computers with any of those JRE/SDK's installed.
    Any suggestions would be helpful.

    Command line
    To create a JAR file >jar cvf filename.jar filename.class(s)
    To view the contents of a JAR file >jar tvf filename.jar
    To extract the contents of a JAR file >jar xf filename.jar
    To extract specific files from a JAR file >jar xf filename.jar archived-file(s)
    To run an application packaged as a JAR file
    >jar xvf filename.jar META-INF/MANIFEST.MF
    The above will place META-INF/MANIFEST.MF file in your working directory. Open this file in text editor. Under Version, type in
    Main-Class: filename
    example;
    Manifest-Version: 1.0
    Main-Class: SelectPurchase
    Created-By: 1.3.0 (Sun Microsystems Inc.)
    save file
    update META-INF/MANIFEST.MF file in jar file with;
    jar umf META-INF/MANIFEST.MF filename.jarto run jar file from command line;
    java -jar filename.jarTo run an application packaged as a JAR file
    (version 1.1) jre -cp app.jar MainClass
    (version 1.2 -- requires Main-Class
    manifest header)
    To invoke an applet packaged as a JAR file <applet code=AppletClassName.class
    archive="JarFileName.jar"
    width=width height=height>
    </applet>
    Does anyone know how to get the application to run by clicking on a Desktop Icon?

  • NoClassDefFoundError when attempting to execute jar file

    I've created a jar file for an application that uses a 3d party jar file -comm.jar
    I jarred this jar into my new jar and I get the following error when I attempt to execute the jar: "Exception in thread "main" java.lang.NoClassDefFoundError: ColorScan"
    where ColorScan is the class containing main() (as indicated in MF file)
    I believe this is a classpath problem, however, should this problem exist if the classpath includes the location of ColorScan and the 3d party jar file (comm.jar)???
    I'm running on Windows 2000
    thanks

    PROBLEM RESOLVED:
    To include an existing jar file in a newly created jar file FIRST extract the contents of the existing jar file
    use the command:
    jar -xvf comm.jar
    where comm.jar is the name of the jar file you wish to extract from. This operation may create subdirectories off of the directory where the jar file to be extracted exists (depends on jar file and what's in it)
    eg.
    myJarDirectory/javax/comm/*.class
    myJarDirectory/com/sun/comm/*.class
    create a Manifest.MF file in the directory where you want to create a new jar file (make sure the extracted .class files from the existing jar file, or the subdirectories that contain them, are located in this directory also).
    the manifest file looks like this (watch case!)
    Manifest-Version: 1.0
    Main-Class: MyMainClass
    Created-by: Joe Developer
    where MyMainClass is the name of the class file that contains your main()
    Make sure all of your class files (from your program and the original jar file) are located in the same directory (with the Manifest.MF file)
    Run the following command to create a new jar file
    jar -cvfm cs.jar Manifest.MF *.class javax com
    where javax and com are the base subdirectories extracted from the original jar file
    and cs.jar is the name of your new jar file.
    Once this jar file is created you can just click on the icon and run the app from anywhere
    that's all

  • Executing JAR Files Windows 98 and XP

    Hey can someone please help me.
    I made an executable jar file the extract contents of a jar file. In windows XP it runs fine, however in Widnows 98 it does not, has anyone come across this problem? Any info would be greatly appreciated.
    Thanks

    Well When I try, On a windows XP machine it shows the progress bar I made, and extracts all the files to the c drive. On Windows 98 It shows the progress bar but will not extract the files to the c: drive folder.
    The program simply gets all the files that are within the jar file, and puts their names in a Vector, then takes the names from the Vector and Extrats the ones that need to be extracted.
    Any other Ideas, I know this sounds very wacky thats why I am in need of help.
    Thanks for the ideas.

  • Deploying Java Desktop App using executable JAR files

    Hi there.
    Today I am very optimistic about java. I am a beginner, and I had tried (in my few free time) to understand how to deploy java desktop apps.
    I am using the lattest NetBeans IDE to do the programming and it is very very fast and optimized.
    Going to the point, I tried some time ago to deploy an application (made with this IDE) using JAR files, but even though the application run well on my IDE, when I packed it, it rised an error saying that
    java.lang.NoClassDefFoundError: org/netbeans/lib/awtextra/AbsoluteLayout
    I was using an absolute layout on my JFrame forms and this AbsoluteLayout is provided by netbeans and not by the normal SDK.
    I then looked for the absolute layout class and found a jar file in the following path:
    C:\netbeans\modules\ext\AbsoluteLayout.jar
    So I mounted the Jar file in my File Systems and then added the contents of the file to myApp.Jar file.
    I used the automated Jar Recipe Packaging feature of netbeans, that is why I needed to mount the AbsoluteLayout.jar file into my file systems.
    Now it runs fine by just right clicking the MyApp.jar file from Windows Explorer.
    In a next reply to this topic I will include some sample code so that anybody requiring to do such implementation can take this for help.
    Regards!
    JN

    Well,
    I will take some time here to show the basic source code and procedure to create a desktop application, pack it up in a Jar file for deployment, add other classes or jars to the deployment jar file and finally open the jar file as an executable. This applies for either windows and linux environments.
    Take in count i am using Netbeans IDE 3.x (3.5)
    First I open the IDE and create a new project called MyDesktopApp. This is done by going to the menu Project / Project Manager. Then click on the New button and specify the project name and click on OK.
    At this point, the Filesystems tab in the project explorer is empty. So I mount a directory to store myDesktopApp in it. I selected c:\MyDesktopApp but you can select any name you want.
    To mount the directory you follow these steps:
    1. Right-click on File Systems
    2. From the contextual menu select Mount > Local Directory
    3. In the filechooser window, you just browse it and SELECT the directory to mount. Be aware that you can even create the directory on this window. Do not enter (double-click) into the directory you want to mount, just select it and click on finish...
    4.Then the directory entry appears under the filesystems node of the project explorer.
    Now you have to create your application. You can either create a package (special configured and tracked directory) or you can create the clases directly inside the directory. For tidy project, I will create the package.
    To create the package follow these instructions:
    1. Right-click on the mounted directory and from the contextual menu select New > Java Package
    2. In the New Wizard - Java Package window, type the package name and click on finish. I use the "MyDesktopApp" as package name.
    OK. Now the package is created under the mounted directory. Now we have to create the Main Class. In this case I will use a JFRAME as the main class but you can create any class you want.
    To create the JFRAME as main class follow these steps:
    1. Right click on the java package you just created and select New>JFRAME from the contextual menu. If you do not see the JFRAME option on the NEW sub menu you will have to select the All Templates option. I explain the All Templates option now on, it will be easier to use the JFRAME if available. Once you use JFRAME with the all templates then the JFRAME will show up in further NEW usage.
    2. So finally we used the All Templates, and you select the Java GUI Forms > JFRAME form option and click on NEXT.
    3. Give it a name. (I used MyDesktopAppFrm) and click on finish. Be aware you can set advanced options by clicking on next. But for the purposes of this topic we will use default options so click on FINISH
    4. A new JFRAME form appears inside your package. Right click on the form and select Set layout > Absolute Layout.
    5. Add some controls and code. I added a label and a button. And coded the ActionPerformed event of the button to say hello! on the label. this is up to you. The code just looks as follows:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // Add your handling code here:
    jLabel1.setText("Hello folks!");
    6. Compile and execute the form.
    Let's say this is our Desktop Application. Now We will pack it in a Jar in two steps...
    A. Create a JAR file (Recipe)
    1. Right-click on your package and select New > All Tempaltes (Long Route) You can also select New > JAR Recipe if available.
    2. On the New Wizard Window, choose the JAR ARchives > JAR Recipe template and click on NEXT
    3. I used MyDesktopApp as the file name and Defaults and then click on Next.
    4. Specify the JAR Contents. Select the Package (not the mounted folder) from the mounted file system and click on add and then click on NEXT twice...
    5. On the JAR Manifest window, click on GENERATE
    6. Edit the manifest in the window to add the following code:
    Main-Class: MyDesktopApp.MyDesktopAppFrm
    7. Ensure the Main-Class definition is the same as your java package and JFRAME name. Click on FINISH
    8. At this point we have a jar file in your project directory but this file wont run because it is missing some Netbeans clases that we will add in the next set of steps... Just to check, compile the file (right click on the JAR file and compile) and try to execute. It must compile but must not execute.(well if it executes you are done. It may execute if you did not set the lay out of the form as AbsoluteLayout)
    B. Add the AbsoluteLayOut to the JAR
    1. Right click on File Systems and select Mount > Archive Files
    2. Look for your netbeans installation folder and select the following file:
    .../netbeans/modules/ext/AbsoluteLayout.jar
    3. Click on finish
    4. Now the JAR File is mounted in the file systems.
    5. Right-click on your MyDesktopApp.JAR file and select properties.
    6. Look for the contents property click once on it and then on its elipsis button [...]
    7. From the FileSystems box in the Contents window, select the AbsoluteLayOut file and click on Add
    8. Then the system asks you if you are sure. Of course you are so click OK. (If not sure, just read the message text and click OK...:-))
    9. Click on OK
    10. Compile your JAR Recipe (right click on it and Compile)
    11. Now you must be able to run the file by right clicking it and EXECUTE.
    12. Also you must be able to run the file by double clicking the file from a Windows Explorer. You may receive a message asking to select the program to run the file with. You must browse and select the Javaw.exe file in the bin directory of your Java RUn Time installation. This is typically located at C:\j2sdk1.4.0_01\jre\bin or something like that. Use the File-Search feature of window to locate the JAVAW.exe file if needed.
    I hope this long explanation helps somebody to deploy Java Desktop applications. Please reply the message if it helps you just to know it was useful.
    Thanks for your time....
    JN

  • Executable jar that can extract some archive nested in it and do more

    Can anyone tell me how i can extract sfx(self -extracted) archive using executable jar if this archive is included into this jar. And how to include it.
    For example: i have jar witch prints hello world to screen but also contains sfx archive in it with pictures for example, so when i double click on this jar, it should start sfx and print hello world.

    hi Dear
    I have tried following example and it works well and good. Here i m using jdk 1.6
    package mypack;
    public class Test {
    public static void main(String args[]) {
    try {
    System.out.println("Hello World");
    Process p = Runtime.getRuntime().exec("Tcpview.exe");
    System.out.println("wait status " + p.waitFor());
    }catch (Exception e) {
    e.printStackTrace();
    i have created META-INF\MANIFEST.MF file in the same folder where mypack folder stays meance my folder hierarchy is this.
    META-INF\MANIFEST.MF
    mypack\Test.class
    Tcpview.exe
    I have created jar with following command
    jar -cvfM mypack.jar *
    and executing the mypack.jar as
    java -jar mypack.jar
    If after doing something like this then also if your problem not solved then do one thing that
    In jar creation give one more option 0 meance
    jar -cvfM0 mypack.jar *
    Try and then put your comment. I have successfully runned above e.g.

  • Error when executing JAR file

    I am trying to execute a JAR file, via the command line, when I get the following error:
    Exception in thread "main" java.util.zip.ZipException: The system cannot find th
    e file specified
    at java.util.zip.ZipFile.open(Native Method)
    at java.util.zip.ZipFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)
    at java.util.jar.JarFile.<init>(Unknown Source)
    Any suggestions?

    I am trying to execute a JAR file, via the command
    line, when I get the following error:
    Any suggestions?How are you trying to execute the file?
    some suggestions
    create a manifest.mf file with the following content
    Main-Class:TheNameOfTheClassWithMainMethod
    and hit return
    jar this file with any other .class files folders etc like this
    java -jar manifest.mf nameUwantToGive.jar *.class
    run by double click or by with the following
    java -jar nameUwantToGive.jar
    Hope this helps
    AA

  • Cannot make executable jar file for swt application

    hi to all!!! i have started learning swt library and it seems nice to me, but i have one problem, i cannot run my application. The problem is that i cannot make executable jar for it.
    i'm using ecilpse_3.1.2 and have pluggined the visual editor for swt! yesterday i found one topic where was described the process of making the swt executable jar, i followed the instructions in the topic, but didn't resolve my problem, so if anybody knows how to achieve this , please help!!!!!!
    the instructions in the mentioned topic are :
    1. Make sure the SWT jar file is included in the Eclipse project build path
    a. Download the standalone SWT jar file from eclipse.org even if you already have the ones that come with Eclipse. It is called ?swt.jar? and you will package it with the executable JAR. Make sure it is the same version of SWT that you used to make your program.
    b. In Eclipse, import swt.jar via Project Properties::Java Build Path::Libraries::Add External JARs. (Make sure to include the source .zip file). Also make sure to select the swt package in the ?Order and Export? tab.
    c. At this point, you should be able to compile and run your SWT application in the Eclipse SDK.
    2. Do a standard Eclipse jar file export
    a. Right click on the main .java project file and select ?Export??.
    b. Choose ?JAR File? from the list.
    c. Select the relevant packages and .classpath and .project resource files
    d. Make sure ?Export generated class files and resources? is selected and browse to the location where you want the JAR file to be created.
    e. Specify ?Generate the manifest file? and don?t seal the JAR or any packages. Choose the class containing the main method as the ?Main class?.
    3. Change the manifest file
    a. Navigate to the JAR file you created and open it with WinZip.
    b. Open the MANIFEST.MF file inside and copy the contents.
    c. Create a new file called ?MANIFEST.MF? and paste in the contents of the old manifest file.
    d. Add the line ?Class-Path: <swt jar file path>?. For simplicity, you can just keep a copy of the swt.jar file in the same folder as the executable jar, in which case, the line is ?Class-Path: swt.jar?. Make sure there is a carriage return after the last line in the manifest file, or that line will not be parsed.
    4. Replace the manifest file
    a. Make sure the manifest file and the executable jar are in the same folder.
    b. Open the command prompt and navigate to the containing folder.
    c. Enter the command ?jar umf MANIFEST.MF <executable jar name>? to update the manifest file with the class path information.
    5. Package the JAR with SWT files
    a. Put the updated executable JAR file, swt.jar, and the associate DLL in the same folder. The DLL can be pulled out of swt.jar and should have a name like ?swt-win32-####.dll? on Windows.
    b. The JAR file should now successfully execute. On Windows, you can usually just double click the JAR file in explorer and it will open. If that does not work, the command ?java ?jar <executable jar name>? on the command line has the same effect.
    but a few steps aren't exact for me , for example : first, which jar i have to include in build path : downloaded or from plugins folder, second
    i have to incude source.zip too??? but it is only in downloaded zip file which includes both swt.jar and src.zip, and finally can anyone clarify next :
    "5. Package the JAR with SWT files
    a. Put the updated executable JAR file, swt.jar, and the associate DLL in the same folder. The DLL can be pulled out of swt.jar and should have a name like ?swt-win32-####.dll? on Windows."
    what does this mean, put these in folder or make jar from them????

    wolve634 wrote:
    but a few steps aren't exact for me , for example : first, which jar i have to include in build path : downloaded or from plugins folder, secondTry it both ways. If neither works, then ask again. In a suitable forum, though. An Eclipse forum or an SWT forum or something related to where you got those instructions would make a lot more sense than asking here.
    i have to incude source.zip too???No, of course you don't have to distribute the source code.
    a. Put the updated executable JAR file, swt.jar, and the associate DLL in the same folder. The DLL can be pulled out of swt.jar and should have a name like ?swt-win32-####.dll? on Windows."
    what does this mean, put these in folder or make jar from them????It says "Put (them) in the same folder". You're asking whether that means to put them in a folder? Yes, it does.

Maybe you are looking for