Creating a jar file

Hello all. I am trying to create a jar file for a *"hello world"* program. I compiled the code using netbeans and created the jar file from the HelloWorld.class. I added the main class to the manifest with the following line
Main-Class: helloworld.HelloWorld
Ensured there was a carriage return just before the end of the file.
When I run the program I get the following error:
h1Exception in thread "main" java.lang.NoClassDefFoundError: helloworld/HelloWorld*
Please help

I tried the last command it produced this error
*C:\Documents and Settings\oshonowo\My Documents\Projects\DOS>set JAVA_HOME=c:/Pr
ogram Files/Java/jdk1.6.0_03
C:\Documents and Settings\oshonowo\My Documents\Projects\DOS>set classpath=C:\Pr
ogram Files\Java\jdk1.6.0_03\lib\;C:\Program Files\Java\jre1.6.0_03\lib\ext\QTJa
va.zip;C:\Program Files\Java\jdk1.6.0_03\jre\lib;C:\Program Files\Java\jre1.6.0_
03\lib;%CLASSPATH%;.;C:\Documents and Settings\oshonowo\HelloWorld\build\classes
\helloworld\Hello.jar
C:\Documents and Settings\oshonowo\My Documents\Projects\DOS>"c:/Program Files/J
ava/jdk1.6.0_03\bin\java" helloworld.HelloWorld
Exception in thread "main" java.lang.NoClassDefFoundError: helloworld/HelloWorld
C:\Documents and Settings\oshonowo\My Documents\Projects\DOS>pause
Press any key to continue . . .*
Please help

Similar Messages

  • I Can't Create my jar File

    I have a package called voiceexpert which contains three classes: Disease, DiagnosingEngine and Symptoms which is a JavaBean. Symptoms makes use of Disease and DiagnosingEngine objects.
    voiceexpert is stored in the directory: c:\diagapp3
    I compiled Symptoms.java as below:
    c:\diagapp3> javac -d . Symptoms.java
    The class files for Disease.java, DiagnosingEngine.java and Symptoms.java are placed in the directory: voiceexpert.
    I created a Manifest.txt file inside c:\diagapp3 containing the following:
    Main-Class:voiceexpert.voiceexpert.Symptoms
    Name:voiceexpert/Symptoms.class
    Java-Bean:True
    I later created the jar file with the command:
    jar cfm jjj.jar Manifest.txt voiceexpert\*.*
    But, I am having the error message: "*invalid header field*".
    What can I do to remove this error?
    Note: I created the Manifest.txt using utf-8 encoding. My code is to be used in a third-party application and that is why it does not contain a main method.
    The link I was referred to could not help me. I need help please!
    Edited by: Adeyi on Feb 24, 2010 2:26 AM
    Edited by: Adeyi on Feb 24, 2010 2:34 AM

    Adeyi wrote:
    ..I created a Manifest.txt file inside c:\diagapp3 containing the following:
    Main-Class:voiceexpert.voiceexpert.Symptoms
    Note: I created the Manifest.txt using utf-8 encoding. My code is to be used in a third-party application and that is why it does not contain a main method.Why are you specifying a main-class when the API has none?
    The link I was referred to..What link? Just imagine for the moment that the Internet is a big place and we are not psychic.

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

  • How to create a .jar file for the BPEL project

    hi all,
    how can i create a .jar file for my BPEL project, i am trying to deploy the project but getting an error :
    "Error: [Error ORABPEL-10902]: compilation failed [Description]: in "C:\OraBPELPM\integration\jdev\jdev\mywork\Workspace_BPELDemo\BPEL_Report\BPEL_Report.bpel", XML parsing failed because "". [Potential fix]: n/a. "
    and when doubel cliking on this error Jdev take me to the beginning of the ".bpel" file.
    I 'm really stuck in here i am not able to deploy the process!
    Thanks,
    Rana

    Rana:
    If you haven't already, I would post this question in the BPEL forum. I would expect a much better turnaround there.
    Johnny Lee

  • How to create a .jar file in wlcs3.1

    hello friends,
    hi friends, im working on weblogic commerce server3.1 . i dont know how to create a .jar file in weblogic commerce server3.1. can any one knows send email to me.
    thanks.
    hari

    $JDK_HOME/bin/jar (%JDK_HOME%\bin\jar) shows you the syntax
    where JDK_HOME is your jdk installation directory.
    Kumar
    hari wrote:
    hello friends,
    hi friends, im working on weblogic commerce server3.1 . i dont know how to create a .jar file in weblogic commerce server3.1. can any one knows send email to me.
    thanks.
    hari

  • How to create a jar file which is in the remote system?

    Hi,
    I have a set of files that resides in a remote system,which have to be "jar"red. I have a firewall in between. I want to create a jar file out of the files situated in the remote system.How do i go about this process.?

    Hi,
    You can't do that in a simple way. You need to have a port open in the firewall, and you need to have a server process on the remote machine.
    Kaj

  • How can I create a jar file at a Unix systems?

    Hi there,
    how what's the command to create a jar file in Unix? I'm creating a zip file and then renaming it to jar, but it's size is smaller than the one when I use the WinZip tool at a Windows system.
    Thanks,
    Andre

    Oops,
    it very easy to do. Just use the jar -cvf command
    Andre

  • Exception while creating a jar file for bean

    Friendz,
    I am getting this error whenever i tried to create a jar file.
    I am using win 98 os and jdk1.4 please tell me what error it is
    C:\bean\programs\spectrum>jar cfm a.jar manifest.mft spectrum.class
    java.io.IOException: invalid header field
    at java.util.jar.Attributes.read(Attributes.java:355)
    at java.util.jar.Manifest.read(Manifest.java:162)
    at java.util.jar.Manifest.<init>(Manifest.java:52)
    at sun.tools.jar.Main.run(Main.java:124)
    at sun.tools.jar.Main.main(Main.java:904)
    Contents of manifest template file:
    Name:spectrum.class
    Java-Bean:True

    Manifests are saved with the .mf file extension. Rename your manifest mainfest.mf.

  • Create a jar file using the jar tool

    Hello all,
    can somebody help me with this situation:
    I use the following comand
    jar cfm Seti.jar manifest.mf SetiSeti.jar is the name of the file I want to create and Seti is the name of the folder where I have the class files, the manifest file and the Seti.java. The manifest file is also out of this folder (exactly the folder were I use the command on the command line).
    After creating the jar... I try to run it but it gives an error message: "can't find the main class..."
    The content of the manifest file is:
    "Manifest-Version: 1.0
    Main-Class: Seti
    I'd never created a jar file before and have already read all the usefull information here and at sun... I'm very preoccupied with this..
    Can you help?
    Thanks

    RuiAranhaJava wrote:
    How do I do this?
    "And you have to name that package as well when you name the main class in the manifest. "
    But, as I have told the name of the package is SetiNo, you just told us that the name of your class is Set. You never told us about the name of the package.
    Simples question possible: Does your class look something like this:
    package Seti;
    // maybe there are some import statements here, maybe not
    public class Seti {
      // maybe there's something here, maybe not
      public static void main(String[] args) {
        // anything
    }If so, then the fully qualified name of your class is "Seti.Seti" and you need to write that into the Main-Class attribute. (*)
    If there is no package-Statement, then the fully qualified name of your class is simply "Seti" and the Main-Class attribute is correct, but your classes are in the wrong place.
    Edit:
    (*) Please note that package names should generally be all-lowercase, so it should be "seti" instead of "Seti". This helps distinguish it from the simple names of classes, so it's easy to see what you are talking about at a glance: "seti" would be the package, "Seti" the class name.

  • How do you create a jar file in JDeveloper 11.1.2.0.0

    How do you create a jar file in JDeveloper 11.1.2.0.0

    1) Select the project for which you would like to generate the jar.
    2) Right Click the selected right and select 'Project Properties'
    3) Select the 'Deployment' in the left tab.
    4) Click on 'New' to create a new deployment profile and in the popup dialog, select 'Jar File' profile type and provide the name.
    5) Press 'ok' to save the changes.
    6) Select the project and right click and select 'Deploy to' and select the jar profile name you have specified.
    The Jar library is generated and the full path to the library jar is shown in the log window.
    Thanks,
    Navaneeth

  • Help To Create a Jar File

    hi there
    i wanna create a exe file so i am trying to use jar file.
    I am new at creating jar files, my application has a main file and other java files, i am using other java files in my main file my concern is can i create a jar file including all the files and when i run jar file i want to complie java files, i really appreciate if anyone can help me out creating a jar file to compile and execute java files

    http://java.sun.com/j2se/1.4.2/docs/guide/jar/index.html

  • A program that creates a JAR file

    Hello,
    I want my program to generate a JAR file with the content of a folder, by I just don't know how to to this.
    I don't find any help about this and I wonder if it is possible.
    Can someone help me ?
    Does someone know if it is possible to create a jar in a program, and if yes, how to do ?
    Thanks a lot
    Lio

    (I think Lio wanted to create a .jar file in his program, rather than an external program that could create files for him?) The java.util.jar package has classes for creating jar files. They are quite easy to use. You can use this code as a reference:
    http://javaalmanac.com/egs/java.util.zip/CreateZip.html
    (nevermind the fact that the code creates a Zip file rather than a Jar file; the API is so similar you can just replace every occurence of 'zip' with 'jar')

  • Create a jar file

    Hello everybody! :) I really need your help.
    I have Tom.class
    I want to create a jar file.
    I use eclipse, so I created jar file there. I got MarkTven.jar in which:
    Tom.class
    .project
    .classpath
    MATA-INF / MANIFEST.MFin MANIFEST.MF:
    Manifest-Version: 1.0
    Main-Class: Tomclicking at MarkTven.jar I get:
    Invalid or corrupted jar file.Help me please.
    Message was edited by: ghost:))

    I have to say, that although this has nothing to do with me, I'd like to pass some comment. This attitude is prevalent throughout the forums and how can people be expected to gain experience if their efforts will be down-played and you try to make them accountable for their ignorance? It's a contradiction in terms. This is a large forum with more than a lifetimes worth of reading for those of us with a life.
    America70 has given you all the information you require to develop a resolve. I think he/she was depending on you perhaps being aware of a common issue he/she may have overlooked. I would treat that as misplaced respect personally, however, you could have steered him/her towards passing you further detail of his/her issue so that the issue could be resolved. Instead, this query remains, pointlessly, filling up space and uselessly guiding other new leaners no-where.
    You guys may be offering your advice for 'free' but you are also advocates for the language in doing so. Surely you should be making greater efforts to promote the language instead of forcing people to steer clear of attempting to expand their knowledge? It's just an opinion...
    *free - I use this term loosely because the cost to the learner is far from free, the expense being the mentors ego.
    In reference to the above post, America70 had simply made a typo in his/her query to you, not mis-spelt it in his/her implementation; he/she explained that. If he/she is required to add more detail, then politely ask him/her to. America70 also pointed out that he/she had followed the tutorial. It is obvious he/she has mis-read, mis-understood, or badly-impemented something. He/she has obviously overlooked this and is unable to discover the fault. It's not rocket science. If you people can't positively add to this post then what is your use as a helper/teacher?
    Edited by: chewzLife on May 18, 2008 7:50 PM
    Edited by: chewzLife on May 18, 2008 7:51 PM

  • What is the command to create a jar file through Command Promt?

    Hi,
    I done my java project. Now i need to create a exe or jar file to fully complete it. I decided to create a jar file. Because, It'll support both PC and MAC. I exported my JAR file through eclipse. But that jar file loads without images and icons when it is in other directory. How can i include images folder in a JAR File.
    For ex:
    I have parent folder named "Support". Under this there is 3 subfolder namely
    bin - Classes
    src - java files
    images - image files.
    I need to create jar file to "Support" folder which should contain all the above mentioned sub folders.
    I need to execute this jar file anywhere which should not depend on the above mentioned folders which mean adding the images folder in that created jar file.
    Pls guide me for this problem.
    Thanks in advance
    Regards,
    Mohan

    But that jar file loads without images and icons when it is in other directory.Images should be accessed via a URL rather than using a filename because they will exist as entries in the jar archive not as files. Typically this URL would be obtained by using the Class method [getResource()|http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getResource(java.lang.String)]. There are details in this [Java World article|http://www.javaworld.com/javaworld/javaqa/2002-11/02-qa-1122-resources.html].

  • Icons disappear when creating a jar file.

    I am trying to make a runable jar file of an application that i wrote however, when i export it from eclipse the icons no longer appear. All of the icons are contained in a class called gridGui. Any help would be great.
    Thanks
         //Creates all of the icon files used for the buttons
         Icon fiftyCents = new ImageIcon("Fifty_Cents.gif");
         Icon oneDollar = new ImageIcon("One_Dollar2.gif");
         Icon twoDollar = new ImageIcon("Two_Dollar.gif");
         Icon threeDollar = new ImageIcon("Three_Dollar.gif");
         Icon fiveDollar = new ImageIcon("Five_Dollar.gif");
         Icon tenDollar = new ImageIcon("Ten_Dollar.gif");
         Icon freePlay = new ImageIcon("Free_Play.gif");
         Icon blank = new ImageIcon("Blank.gif");
         Icon unflipped = new ImageIcon("UnFlipped.gif");
         Icon oneDollarCoupon = new ImageIcon("One_Dollar_Coupon.gif");
         Icon threeDollarCoupon = new ImageIcon("Three_Dollar_Coupon.gif");
         Icon tShirt = new ImageIcon("TShirt.gif");
         Icon youLose = new ImageIcon("You_Lose.gif");

    You are using the ImageIcon constructor that takes a file name argument. When you create the jar file the source for the images are no longer files but entries in your jar file. You have to access them using the ImageIcon constructor that takes a URL argument.
    The actual URL you use is obtained (eg) from the Class method [getResource()|http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getResource(java.lang.String)].
    Suppose your Fifty_Cents.gif was in your jar file in the folder "images" then you could say:
    Icon fiftyCents = new ImageIcon(getClass().getResource("/images/Fifty_Cents.gif");Note the use of forward slashes and the fact that Fifty_Cents.gif has to be capitalised exactly as it is within the jar file.
    There are other ways of organising the resources - see the getResource() documentation for details.

Maybe you are looking for

  • Vendor name change

    Hello All, I have one contract with vendor X. When I changed vendor's name in vendor master, it is not showing new vendor name in contract where as release order of that contract are showing new name. (If I change another vendor's name then it reflec

  • Set_block_property('emp',default_where,...) with variables

    db and dev 10g rel2 , i am trying to learn about this built-in with variables and the equal(=) operator , i can not use it with variables , so show me please how to use it with number , charachter and date variables . 1- working with number variables

  • SSP PO & Confirmation document no.

    HI Is there anyway to pull the SSP PO & confirmation no created in a specific period or year. Please let me know if any table or report is there to pull the same. Regards Pratap J

  • Aperture 3.1.2 workflow with iMac and MacBook Pro

    Could someone please point me to an article that explains how to have the same library on both machines, while keeping the masters on my iMac? I'd like to use my MacBook Pro in the field and sync or copy images to my Aperture library on my iMac once

  • Where is the date taken from when releasing to accounting an invoice

    Hi all, I'm using tcode vf02 to release accounting a certain delivery (by pressing the green flag). I have to check why the date - bkpf-bldat is not written correctly. Do you know, by any chance where the access to BKPF table is done? The program or