Confusion on jar files

Im creating jar files and writing manifests for them. However, I am confused on how to write manifests such that i get the behavior i want. I want all my class files to be in the jar files and run from there. However when i write my manifest with the classpath: ". [followed by other classes]" It cannot find my main class. However, when I include the classes outside the jar file, the program runs perfectly. I tried ".\[nameofjar].jar" still doesn't work. What do i do??

if you are running it from a jar you have to use -jar with javaw also... thats how javaw knows you are using a jar file and not a class file.

Similar Messages

  • Noob confusion on jar files

    Im creating jar files and writing manifests for them. However, I am confused on how to write manifests such that i get the behavior i want. I want all my class files to be in the jar files and run from there. However when i write my manifest with the classpath: ". [followed by other classes]" It cannot find my main class. However, when I include the classes outside the jar file, the program runs perfectly. I tried ".\[nameofjar].jar" still doesn't work. What do i do??

    I found a really awesome jar packaging program that will do all the packaging for you and write the manifest for you. Its called JarBuilder-0.70 and you can find it on download.com.

  • JOGL jar file confusion

    Some of the jogl.jar file contain following packages
    Packages
    net.java.games.cg
    net.java.games.gluegen.runtime
    net.java.games.jogl
    net.java.games.jogl.util
    another one contain following packages
    Packages
    com.sun.opengl.cg
    com.sun.opengl.util
    com.sun.opengl.util.j2d
    com.sun.opengl.util.texture
    com.sun.opengl.util.texture.spi
    javax.media.opengl
    javax.media.opengl.glu
    Which one is best and latest?

    Packages
    com.sun.opengl.cg
    com.sun.opengl.util
    com.sun.opengl.util.j2d
    com.sun.opengl.util.texture
    com.sun.opengl.util.texture.spi
    javax.media.opengl
    javax.media.opengl.glu
    This is the latest.......

  • Missing .jar files in the Weblogic Server 6.1 beta

    The files /weblogic/lib/weblogic_sp.jar and /weblogic/lib/poolorb.jar are required
    to be set in the
    classpath, according to the documentation. But they are missing in the downloaded
    version of the server.
    Is there any solution?

    Hi Rajashree,
    weblogic_sp.jar file is for service pack. I am assuming that you installed
    latest version from the download site. the latest one is a bundled version
    of wls6.0 with sp2. we put sp2 with 6.0 together, then you do not see that
    jar file.
    I am confused with poolorb.jar file. do you mean wlepool.jar and wleorb.jar?
    those 2 files are used when you need to make a connection pool to WLE
    server. if you do not use it, you do not need to include it in your
    classpath.
    Thanks
    yu
    Rajashree Desai <[email protected]> wrote in message
    news:3b53ea0c$[email protected]..
    >
    The files /weblogic/lib/weblogic_sp.jar and /weblogic/lib/poolorb.jar arerequired
    to be set in the
    classpath, according to the documentation. But they are missing in thedownloaded
    version of the server.
    Is there any solution?

  • Using a jar file in my application... how?

    I have a JAR file which contains some classes I need to use in my application. I however, after looking in several books, cannot figure out how to use this JAR file within my application.
    Do I simply put it in the directory with my .java files, and use an import command? I'm confused.

    If the classes in the jar are part of a package then you can import them based on the package structure. The jar file will have to be part of your CLASSPATH variable.
    i.e.
    myUtils.jar
    resides in C:\"My Classes"
    CLASSPATH = .;"C:\My Classes";"C:\My Classes\myUtils.jar"
    within the jar I have the following class:
    \ameyer\Util\someUtil.class
    \ameyer\Util\anotherUtil.class
    To use these classes I could use the following import statement
    import ameyer.Util.*;
    This would import any class at that level in the jar.
    Note: the import part of the CLASSPATH is "C:\My Classes\myUtils.jar"
    hope this helps.

  • How to put native methods in jar file

    Hi.I have an executable jar file(test.jar) that makes use of other jar files and native methods. For example, test.jar uses Jnpout32.dll. . test.jar , the other jar files and the native methods are all in the same directory. When I created test.jar I wrote a manifest file which specifies the class path of the other jar files and the native methods as follows and provided it as an option in the jar cfmev command.
    Class Path: jdbc.jar Jnpout32reg.dll  //content of manifest.txt  file that I provided to the jar command
    //carriage return I then run the command java -jar test.jar to run the file.
    All I am seeing is the following error message
    Exception in thread "AWT EventQueue-o
    "Java.lang.NoClassDefFoundError.
    gnu/io/SerialPortEventListner"
    {code}
    Any ideas? thanks in advance!
    Edited by: Nostalgia on May 22, 2009 8:05 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You seem to be confusing Java's classpath with your os's path. The classpath only applies to Java classes. See if this discussion helps:
    http://www.inonit.com/cygwin/jni/helloWorld/load.html

  • Importing .jar files

    I have been checking out the forums and I think I am more confused than before. I have a bunch of classes in a .jar file and I want to use them in another app. I haven't changed what my classpath is because it has been so confusing I decided to reinstall the j2sdk. What should I set the classpath too? I have my class and the .jar file that I want to use in C:\Java Stuff\. What import statement do I have to have if the name of my .jar file is MyClasses.jar?
    Thank you!

    What you're saying is that your directory structure is something like this:
    C:\Java Stuff\com\mydomain\myclasses\MyClass.class
    C:\Java Stuff\MyJar.jarIf this is the case, you don't have to extract the files from the jar file into the directory. The jar file contains all the files and Java is able to fetch them directly in the jar file.
    However, to do this, your class path must include the jar file, and not just it's directory.
    So instead of:
    CLASSPATH=c:\j2sdk1.4.0_02\bin;c:\Java Stuff;you must have
    c:\j2sdk1.4.0_02\bin;c:\Java Stuff\MyJar.jar;Hope it helps!

  • How to include externel library in JAR file?

    Hi all =)
    I have a program that uses an external library (in a JAR file) I would like to compile my program as a JAR and have it include the external library that it needs to run, so that the external library would not need to be on the computer running my program. How can I do this?
    Thanks =)
    Koneko349
    Message was edited by:
    Koneko349

    Ok I was able to make my JAR and launch my application correctly. However whenever I click a button that has a method using my external library I get the following error:
    C:\Documents and Settings\Koneko>java -jar D:\Mangment.jar
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem at managment_system.ManagmentGUI.getNextStat(ManagmentGUI.java:569) at managment_system.ManagmentGUI$1.actionPerformed(ManagmentGUI.java:195)
    I do not get this error when I run and use my program from within the IDE.
    The JAR that has my external library (and has the class for POIFileSystem) is also on my D drive and i referenced it correctly (I think) In my classpath:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path=""/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
         <classpathentry kind="lib" path="D:/poi.jar"/>
         <classpathentry kind="output" path=""/>
    </classpath>I would really like to get this working and I'm very confused XP

  • JAR Files...great

    So...me and some friends wrote some personal financial software (pure java) and it is pretty much complete. With only one problem though. An execitable like file that can be clicked on and ran (yes, I know a JAR File) but we have 18 text files used as help files and a database (Access...java level 1 standard odbc jdbc bridge driver...I know not the best idea either) and we have to get those files to be read by any computer we install our program on. There in lies my question...
    I have not work with JAR files very much but do know that they can be a pain. Is it possible while using a jar to install those 18 help files and the database onto the user's computer. Know where they are and interact with them. Thank you for any help.

    didittoday wrote:
    maybe you got confused...I don't have any jar's I want to make a jar or an exe to run my application me and my friends wrote. I have 18 help text files and and Access database that I want to be able to interact with after we package everything togethermaybe you are the one that's confused
    you can zip or tar all your files and distribute them
    there is no need for a jar or exe
    the access database is another story
    if you need to install that then your client needs to install or you need an installer (MSI or whatever) program
    Edited by: wpafbuser1 on Feb 19, 2008 1:58 PM

  • Java Jar files, and what is needed to run them?

    I'm sort of confused on what happens with JAR files, because on my computers that have all of the java SDK's and programs installed it works as an executable. But on my computer that doesn't have java installed(except for the windows xp basic) it wont work or registers with winRAR.
    My question is, is what needs to be installed on the computer to get an executable jar file to work. Is it JRE, or the SDK? And where can I get the file/s that may be needed to be installed.
    Thanks for the help

    jre stands for java runtime environment, i.e. everything you need to run a java application on your computer.
    sdk stands for software development kit, i.e. everything you need to develop java applications
    the jre run jar files for sure

  • Using .jar files

    I was able to use .jar files in Java programs that I write on my computer. I could write a program that used an import statement to bring in classes contained in a .jar file.
    One day, I was trying to incorporate a jar file folder directly into my windows operating system by using the environmental variable called CLASSPATH. Unfortunately, I made the mistake of screwing up my PATH variable. I fixed my PATH variable back up by adding the directory to the bin folder inside of the Java folder as is described commonly by the documentation for installing the Java SE on windows computer.
    Since that day, I have not been able to use .jar files using an import statement. My computer is unable to find the .jar files even if I specify the exact directory. Even the IDE(netbeans) that I use is unable to find and use .jar files. I have found that I can open up .jar files and pull the contents that I need out of said .jar files, but I have a project that does not allow me to open up the .jar files and extract the needed classes.
    I have googled this problem so much that I have read hundreds of posts about .jar files, and I cant find anyone in a situation that is similar to mine. If I take my files to another computer with Java SE installed, then my source code can access the .jar files just fine. For some reason, my work computer seems to hate using .jar files. I have no idea what could be the problem. There is no information in the java documentation on troubleshooting with this problem, and the most confusing part is that it worked perfectly fine until That one day
    Does anyone have any ideas?
    Specific technical details:
    I need to pull the Stopwatch.class file from a stdlib.jar file. In the past I had done this by using an import statement inside of my program:
    "import stdlib.Stopwatch; "
    Using this command to compile:
    "javac -cp .;(directory path to .jar file); source.java"
    This used to work. Now when using the javac command I get error messages
    1. Error points directly to import statement. Arrow directed at the period after stdlib.
    "cannot find symbol"
    2. Error message pointing to all instances of the class that I was attempting to import into my program.
    Thanks for reading
    Edited by: 955611 on Aug 28, 2012 7:22 PM

    I read your post. I want to compile this project by using the "-classpath" option in the javac command. After screwing up important system variables once, I do not want to continually have to play with system variable in order to compile projects. To quote from the website that you linked:
    Using the JDK tools' -classpath option
    The JDK tools java, jdb, javac, and javah have a -classpath option which replaces the path or paths specified by the CLASSPATH environment variable while the tool runs. This is the recommended option for changing class path settings, because each application can have the class path it needs without interfering with any other application.
    The runtime tool java has a -cp option, as well. This option is an abbreviation for -classpath.
    For very special cases, both java and javac have options that let you change the path they use to find their own class libraries. The vast majority of users will never to need to use those options, however.
    Clearly, the "-classpath" option in the javac is intended to replace the need to play with important system variables. I guess my post boils down to the question of "Why doesn't this command work for me?". I followed your suggestion by removing the bin directories and adding the stdlib.jar directory directly into the system variable itself. Here is the following output from my command prompt:
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Lelo>E:
    E:\>cd Programs\Java
    E:\Programs\Java>javac testy.java
    testy.java:1: error: package stdlib does not exist
    import stdlib.Stopwatch;
    ^
    1 error
    E:\Programs\Java>echo %CLASSPATH%
    C:\Program Files\Java\jre6\lib\ext\QTJava.zip;E:\Programs\Java\stdlib.jar;
    E:\Programs\Java>javac -classpath .;E:\Programs\Java\stdlib.jar; testy.java
    testy.java:1: error: package stdlib does not exist
    import stdlib.Stopwatch;
    ^
    1 error
    E:\Programs\Java>
    I still received the same errors. It seems that even adding the directories into the system variable will not work for me.

  • Loading library from jar file

    Hi all,
    My question is can we load library from jar file using System.load() method.
    ex:
    myJar.jar
    |
    |----com.test.common.Util
    which conatins a method to load library from jar file itself, before that i used to load from File
    |---libraries/MozillaParser/......
    Iam able load from Local system,
    File parserLibraryFile = new File("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    File mozillaDistBinDirectory = new File("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(parserLibraryFile.getAbsolutePath() , mozillaDistBinDirectory.getAbsolutePath());
    but i am unable to load from jar file
    URL url = ClassLoader.getSystemClassLoader().getResource("libraries/MozillaParser" + EnviromentController.getSharedLibraryExtension());
    URL url1 = ClassLoader.getSystemClassLoader().getResource("libraries/mozilla.dist.bin."+EnviromentController.getOperatingSystemName());
    MozillaParser.init(url.toString(), url1.toString());
    Thanks in advance.

    That's a really confusing post.
    The easiest way to make sure you can use the classes in a jar file is to copy the jar file to the "/jre/lib/ext" subfolder of your JDK. These classes will be visible to all applications.

  • How do I load property files and images stored in the jar file?

    Hi
    So, if I have a structure like this:
    /com.myfirm.myproject.SomeClass
    /images/
    /properties/
    And I pack this structure into a jar file, how do I then access the images under "/images/" and the property files under "/properties/"? A link to a good tutorial on this would be perfect, or a description/hint/howto :)

    Im having problems even loading direcly from the directory..? I have this structure:
    src (source dir)
    classes (classes dir)
    lang/textRb_en_US.properties (the file I want to load)
    Then I have this code:
    Locale currentLocale = new Locale("en", "US");
    ResourceBundle textRb = ResourceBundle.getBundle("/lang/textRb", currentLocale);But it gives me a "java.util.MissingResourceException: Can't find bundle for base name /lang/textRb, locale en_US". I start my application from within Eclipse, and I have tried to move "lang/textRb_en_US.properties" into the classes dir, but same error.
    Im confused as to there Java looks for ressources, and I need this to work no matter where I put my classes/jar. Could you help me out here?

  • Help : Sending Jar file using bluetooth.

    Hi
    I have done till below...
    Midlet will search available bluetooth device in range.
    I want to do below.
    1. Search available bluetooth device in range
    2. User will see list of devices.
    3. when user will select a device, i want to send the jar file itself ( i have stored jar file inside resources)
    4. on file sent to bluetooth devices, it should tell file sent successfully.
    More :
    I am confused with Bluetooth server and client terminology.
    Here my program is client or server ? Infact the whole pupose is we have made some Java program and we want to make it viral, easy for our users to send it to their friends via bluetooth
    Any pointers ?
    Raxit
    www.m4mum.com

    Hi,
    You might wanna look take a look in the JSR 82 Specifications. There is a method like agent.startInquiry(); that starts a search for nearby BT devices. All you have to do is place each found device in an array of type Vector.
    It would have been easier if your code or a snippet of it was available to see what the problem was.
    Rambo.
    PS: A client application application starts a connection on a server application. Where you put them is up to you.

  • Jar file problem , please help

    Hi guys , i am not sure if i am in the right place to have this post in so i'll give it a try
    i know my explanation might be a shot in the dark but i'll try my best
    i have made a program using eclips , to send emails using my email , on certain conditions
    so when that codition happenes on some class in my program
    this class will call the email class and send an email to someone
    now the problem is not in the program , because as along as this program is in eclips and i run the program in eclips , everything goes fine , No errors what so ever
    but , if i make jar file , using eclips "export"
    once i run the program , the program would run , but once the same condition that ihave specified previously happenes , the current class never calls the email class , and no emails would be sent
    i am very confused wether
    1) it throws a class not found for some wierd reason
    2) or the external library that i used to send emails , is not exported
    i tried to check the CLASSPATH file and i think everything seems to be fine , so i dont know what the problem is
    so in short
    if the program is in eclips , every thign goes fine
    if the program is a jar file , then it would work fine but once it needs to send an email , it never does and i can still work on the program , but no emails will be sent
    thanks please some one help me out with this

    for more information here is the senario
    because i see that you guys are some how lost because i am not providing enough information
    so this is a detailed info of the problem
    i have 3 classes
    1) mybankmain (jframe)
    2) mybankbody (all labels and buttons and events included here)
    now: within some events in my program ,
    it calls a class called.....
    3) myEmail
    this class imports two things that are comming from an external jar file , so in short , if the external jar file is not available the program would complain
    i run this on windows xp (SP2)
    now: if this program runs on eclips , it would do everything it is supposed to do and all kind of calculations will be done and emails will be sent on the conditions that i have specified within the program
    if i make a jar file on windows , and i run the jar file , the file would work , all functionalities will work
    EXCEPT: sending an email
    - either my class is not found
    - or external jar file is not found which causes my class not to be able to perform its tasks
    i did only one test
    which is that i switched the main and i made myEmail as a main and i tried to export the jar file
    Result: jar file doesnt work
    the way i view whatever inside my jar file , i use Winrar and it would view everythign in the jar file and i see that all my classes are included there
    if i open my CLASSPATH , i see that there is a pointer to the external jar file
    if i open my manifest : i DO NOT see the exrernal jar file in there but i do see that its pointing to my main class
    class main : mybankmain
    and there is only the version and signiture
    i hope all these additional details would help in determining the problem that ihave been trying to solve for 2 weeks now

Maybe you are looking for