Bundle classes automatically into a JAR

By a single command line, how can I bundle several compiled java classes (*.class files) into a jar file? Say, for example, I want to do something like this:
javac *.class -someoption myClasses.jar
That is, in the end, all my *.class-files are bundles in myClasses.jar. Any idea?

Have a look at the tutorial about JARs. It will tell you about the jar command.

Similar Messages

  • Conversion of a .class file into a .jar file

    Conversion of a .class file into a .jar file
    How Will I convert a .class file into a .jar file.
    Pls answer ASAP.

    You don't.
    You add a .class file into a .jar file. You don't convert anything.
    Read the help page for jar for details.

  • Beginner: Can't convert a hello.class file into a jar file: HELP PLEASE!!!

    Hi, I created a hello.java file, converted into a hello.class file by using the java 2SDk compiler. The problem is that the hello.class file is in a directory I created: C:\JavaBuilder\hello.class
    I have a problem converting the hello class file into a jar file. I don't know which approach to take. I've looked at tutorials...but I keep getting more confused each time I view the tutorials on creating jar files. Please can someone help..by taking me through a step by step process. Please be explicit and do not leave or assume that I know any details because I'm a new born beginner. Thank you very much, I seriously appreciate it.

    Hi i did as you suggested, only with these exceptions:
    jar -cvf hello.jar C:\JavaBuilder\hello.class
    I did this and got the message: "adding : C:\JavaBuilder\hello.class (in=1150) (out=708) (deflated=38%)"
    The problem is that when I tried to execute the jar file...by typing: " java -jar hello.jar" I received the error message: "Failed to load Main-Class Manifest attribute from hello.jar" Is there any way to correct this problem? please help, thank you.

  • Beginner: Can't convert a hello.class file into a jar file. Please Help!!!

    Hi, I created a hello.java file, converted into a hello.class file by using the java 2SDk compiler. The problem is that the hello.class file is in a directory I created: C:\JavaBuilder\hello.class
    I have a problem converting the hello class file into a jar file. I don't know which approach to take. I've looked at tutorials...but I keep getting more confused each time I view the tutorials on creating jar files. Please can someone help..by taking me through a step by step process. Please be explicit and do not leave or assume that I know any details because I'm a new born beginner. Thank you very much, I seriously appreciate it.

    Hi!
    first of all, you should use an upper-case character for the first letter of your classes...
    To answer your question :
    1) you must create a directory named "meta-inf" in your directory "C:\JavaBuilder"
    2) then,you must create a file named "manifest.mf" in this directory
    it's like a property file and it must contain this :
    Main-Class: hello
    (don't forget to type <enter> after "hello")
    3) in the directory "C:\JavaBuilder", you can enter the following command :
    "jar cvfM hello.jar meta-inf\manifest.mf hello.class"
    (check jar.exe is in your path)
    4) you can run your jar by the command :
    "java -jar hello.jar"

  • JSF resource bundle class not found,

    When I put the resource bundle class in session-ejb.jar, it works fine. But when I moved the resource bundle class into web module web.war, JBoss AS complained: the resource bundle class were not found.
    In the web module, I put the bundle class under:
    /WEB-INFO/classes
    war file:
    /WEB-INF/classes/resource/Messages
    JSP file:
    <f:loadBundle basename="resource.Messages" var="bundle"/>
    Thanks for help.

    has anyone made the following example work in JBOSS?
    http://www.coreservlets.com/JSF-Tutorial/code/jsf-messages.zip
    I got error message:
    resouce bundle not found.
    The resource properties files are under WEB-INF/classes.
    Where to put resource bundle files?
    Can any one please shed some light? Thank you very much.

  • How do I read the images I bundled into the jar file?

    I just wrote an applet that uses
         Toolkit tk = Toolkit.getDefaultToolkit();
         tk.getImage("blah.gif");to load a bunch of image files. The class file and gif images were bundled into a jar file to minimize the number of connections the browser has to make to the server.
    The applet works fine in appletviewer but trips a java.security.AccessControlException: access denied (java.io.FilePermission select.gif read) when run in a browser. I know you normally use Applet.getImage(URL) to load images but wont that circumvent the JAR file and make a seperate connection to the server for each image? That would defeat the purpose of using a JAR file.
    How do I access the image files I bundled into the JAR file?

    From your Applet class, write the following:
    URL imgUrl = getClass().getResource("blah.gif");
    Image img = getImage(imgUrl);The returned URL will be from the Applet class ClassLoader, which will look into the specified archive (jar) file.

  • Conversion of a .jar OR a .class file into a .exe  file

    Can anyone tell me as how to convert a .jar OR a .class file into a .exe file
    I need to know as soon as possible.

    Okay I will tell you the steps:
    Look in the top right hand corner of the page.
    There should be a box with a red title line. Inside the
    title should be the letters 'S E A R C and H'.
    In the white part of th box should be a smaller line, in which you can type.
    type in "conversion .jar .class .exe" or some similar string.
    Then click on the button next to the text box.
    Read the page of results you get.
    Click on the first link and read what is said on the connecting page.
    If that doesn't help, use your browser's back button and click on the next link, and repeat util your question is answered.

  • Problem accessing classes when moved into another jar

    Hi,
    I have written some classes and want to put them in an external jar
    as a library. However, when I do this, I have to include the full path
    for them to work- what am I doing wrong? I am using JBuilder6
    Example:-
    I have a class called LogWriter in package org.MyClasses.utils which I
    am using in a class in another package (com.MyCode). If they are all in
    my src directory it works fine and I import org.MyClasses.utils
    If I compile org.MyClasses into a jar and add the jar as a library, I can
    see the classes with CodeInsight (so I know they are there). However, the line
    Logwriter.writeLog() ; (call to static method), which used to work, now only works
    if I change it to org.MyClasses.utils.Logwriter.writeLog() ;
    Any advice?
    MArk

    If the class was called MyWriter and is in org.MyClasses.utils, I have to replace all instances of MyWriter with org.MyClasses.utils.MyWriter.
    MyWriter has not altered in any way. It's now compiled separately and put into another jar rather than all classes being comipled at the same time.
    MArk

  • How to package other jar files into one jar?

    How to package other jar files into one jar? How can i get the class in the inner jar file?

    Generally not a good idea. The Java runtime won't be able to load classes from those "inner" jars, you'd have to write your own classloader to do that. It's not a brilliant idea, generally, anyway, since the point of having lots of jars is to keep your application modular. Bundling them all together like that means you have to re-deploy the whole thing to fix, for instance, one small bug in one small library
    If you really want to do this, there's an Eclipse plugin called FatJar, but I urge you to consider whether you really want to do it first.

  • Taglib: class not found in jar-file

    I've got the following problem:
    I whant to deploy a taglib to tomcat 5.0.25.
    If I point to the jsp which uses the taglib I got the following error:
    org.apache.jasper.JasperException: Unable to read TLD "META-INF/taglib.tld" from JAR file "file:/C:/Programme/Apache Software Foundation/Tomcat 5.0/webapps/taglibtest/WEB-INF/lib/gsa_prod3_db_taglib.jar": org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: ch.gsa.prodass3.taglib.TagAddAttributeTEI
    If I copy the taglib.tld out of the jar-file into WEB-INF and do the mapping in web.xml, I get this error:
    org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class: ch.gsa.prodass3.taglib.TagAddAttributeTEI
    root cause
    java.lang.ClassNotFoundException: ch.gsa.prodass3.taglib.TagAddAttributeTEI
    It seems like none of the files in the jar-file could be loaded.
    Has anybody an idea?
    Help would be very appreceated!
    Greetings, Jonas

    1 - double check the class is in the jar file, in that path, and is spelt correctly
    2 - restart Tomcat
    3 - check the contents of the tld file - particularly the extra-info tag and class name for it.

  • How to create an object of a class contained in a .jar?

    My application must use an API that is stored in a jar file. For example, in my Api.jar I have classes named Api, MyClass2, MyClass3, which have their methods declared public static.
    I don't know from where to start realy. This is what I did:
    I set the CLASSPATH to where my jar is. In my project properties, I added the jar as the first required library.
    If in the java class where I am calling a Api.method1() I import my class with 'import MyClass1;', I get the error: "Error #: 361 : class required, but identifier found at line 20, column 1". Of course, if I don't import it, I get another error: "Class Api not found"
    Is this problem caused by the fact that my jar's name is the same with one of the classes zipped in it?
    How to solve the problem?!? I read all the documentation regarding jars, I didn't come to a better understanding :( Can anyone provide me a sample with the use of a jar? Thank you!

    Do your classes have a state their package?
    Don't forget your Jar files manifest must also state its package. This is my problem - I am using a third party .jar file, which contains 3 classes not included in any package (practically they are only zipped into a .jar). I don't know how to access them...

  • How to run class files in a jar independently.

    Hello all
    I have a java file which use an API.jar file which is an API file of some other application of mine.This file form a sought of client for that application.Now i want to run this file from command line which is giving NoClassDefFoundError exception.This exception is because of the dependency over API.jar.I dont want to pack this single file into a jar and then run that jar since it only makes a simple task complicated and makes a simple class look like a big application.Can anybody tell me the solution to it?
    Regards,
    Mansi

    MansiSachar wrote:
    I am working on WindowsXP and the command u just sent is again giving the same exception.The exception is :
    Exception in thread "main" java.lang.NoClassDefFoundError: ûcp
    Caused by: java.lang.ClassNotFoundException: ûcp
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    I think the problem can also be the placement of the dependant jars.do i need to keep them in "bin" folder?I am assuming that in the error message, it says "-cp" not "ûcp" Can you confirm that you entered the command as posted? Because it looks like java.exe sees the -cp as the class to execute instead of the classpath option.
    Try using -classpath instead of -cp. What version of java are you using? (java -version should give you the version).
    If the jars are in the current directory, the placement of the jar files is correct.

  • Converting a .class file to a .jar file

    Can you please suggest as how can I convert a .class
    (dot class) file into an executable .jar (dot jar)
    file and how I can execute that .jar file.

    use jar tool named JavaJar..
    may down from http://www.pivotonic.com

  • Classes not found for jars listed in manifest

    I have an applet whose main jar has a number of dependent jars listed in the manifest. All the jars are signed.
    The applet works fine when downloaded from an HTTP server.
    Previous to 1.6.14 it would also run from a local directory.
    As of Java 1.6.15 and 1.6.16, the classes in the dependent jars are no longer loadable from the local directory. ClassDefNotFound is the reported on the java console. Obviously the class is present, as the application is running fine in JVMs 1.6.14 and previous.
    I see that 1.6.16 includes changes for the security baseline, but I cannot find anything that suggests changes are needed to support dependent jars. None of the dependent jars request a specific version of JRE.
    Anybody know what is going on?

    Is this the error? ...Yes, sorry, the exception is NoClassDefFoundError
    If you provide a Short, Self Contained, Correct Example someone may be able to diagnosis the problem, as opposeed to guessing. A link to the real live application can be found at: http://download.equitrac.com/38834/InstallGUI.html. (This original application does not meet the definition of short ... but demonstrates the problem well.)
    When run as an applet off this site, it works fine.
    If you click on the download button, it will place a copy on your local harddrive. To execute it locally double click on your local copy of InstallGUI.html.
    When running it locally with Java 1.6.15 and 1.6.16 it will give you a class def not found exception without doing any thing.
    When running locally with Java 1.6.14, it will not experience any trouble.
    This applet needs permissions to open sockets and store data on the harddrive.
    Probably due to the presence of class files that once existed outside of the jars, but are now not thereClose ... the application is made up of a main jar (our product) and a number of third party jars. The manifest for the main jar properly references the other jars, and works in all JVMs before 1.6.15. As of 1.6.15, none of the classes from the referenced jars can be opened.
    I found that I can work around the problem by placing all classes into a single jar ... which may infringe on licensing requirements for some of the third party jars we use.
    Dave

  • Should I split 1 large JAR into smaller JARs?

    I'm not sure how to deploy my application. It's composed of about 50 classes and at the moment compiles into one big JAR. Is that how things are done? I was wondering if I should split the application into smaller JARs according to function, as if I have to make a fix to one part, I then just distribute that one smaller file. Is this something that takes a lot of work to modify the code to make it work, or do I just select the classes in Eclipse and create the JARs? Or should I just not bother, and send out one big JAR?
    Thanks

    Hi There,
    First of all, I must tell you that making a 'jar' file an ddeploying that only to the AS will not do...... You gotta make an 'ear' or 'war' that will consist of the 'jar' files and give the 'jar' file in the Classpath....... If you use JNDI fo Database Connection, 'xml's must be written and configured correctly.....
    Secondly, a 'jar' file might contain 10 to the power Infinity class files--so, that is not a problem...... make sure that only class files r put into and not anything else like the 'java' files that might make the 'jar' big.....
    I think, I answered to your queries...............
    Now, if you face problems again, please be more specific in what you want in the forum.........
    OK Buddy, Cheers !

Maybe you are looking for

  • Questions on the technical feasibility of some desired functions in OBIEE

    Question1: Is the functionality shown in the picture (URL link) below possible? http://hi.erp100.com/attachment/200902/13/26518_1234504624r78c.jpg Question 2: Can we achieve the functionality shown in the picture(URL link) below? http://hi.erp100.com

  • Very Annoying EXPORT problems

    The first time i installed Lightroom, all the things went well, but i don't know why, one day i tried to export a photo and it appeared one of those common errors with "Send Error Report/Don't Send Error Report". I can't do anything besides the prese

  • SSO fails - userPassword having special characters

    Hi, This is a tricky situation i'm handling. I did a insert of around 1000 users into Sun DS whose userPassword contained special characters accepted by DS. mainly + and ;. For seeing if authentication will work, i just created a user through AM Cons

  • How to clear the image after NetStream.attachVideo(null)

    hello,every one. i got a problem.need your guys' help. i create a normal NetStream object,then i publish video from my webcam,meanwhile,i set a Video object to play that stream,when i use NetStream.attachVideo(null) to stop publish video,the image in

  • Strangest thing! Masthead doesn't display Personalize link.

    Hi All, I have enable "Show Link in Masthead: Personalize" option in my masthead iview, but "Personalize" link is NOT displayed. The strangest thing is because when i see generated html source code (right click in browser >> view source) is IS there.