Classpath and jar file question

my application need to use few jar files i downloaded from the internet
so i need to set the classpath so that i can import the packages in the jar file rite?
let say set classpath=.;c:\somedir\bin;
the ".;" after the "=" means that i search the current directory first then search the directory i have specified after that rite?
if so, can i put all the needed jar files in the current directory so that my application can use them??
Another question is if all the jar files in located in the same directory how can i set the class path to refer to them without sepecifying each of the jar file name??can i just put the directory path and will it locate them automatically when my application start??
can anyone tell me about it??thanks

No, you need to include each and every jar file in your classpath.
Or put them all in your <jdk_installation_dir>\jre\lib\ext directory, so that they will get included in your classpath automatically.
Sudha

Similar Messages

  • Question about classpath and jar file

    I have a jar file (actually jhall.jar, the java help jar file). How do I uses its classes if I don't want to add it to the classpath. Currently, I have the jar file in the same directory as all my other classes.

    it simply adds secondjar.jar into firstjar.jar, rather
    than extracting secondjar.jar's files and put it into
    firstjar.jar. How would I be able to do that?Don't do either of them. Distribute the two jar files separately, and in the manifest of the one which is meant to be your executable jar file, put a Class-Path: entry that refers to the other one. Look at the latter parts of the tutorial about jar files:
    http://java.sun.com/docs/books/tutorial/jar/basics/
    PC&#178;

  • Classpath and jar file

    Hy,
    I have written an application that uses the javax.comm package.
    My application contains many classes disposed in \classes directory.
    The main class is admin.class.
    If launch the application with a batch file (in Windows):
    echo off
    cls
    java -classpath c:\hy\classes;C:\jdk1.3.1_02\lib\comm.jar admin
    All works fine.
    if I insert the classes of the application in a jar file, hyper.jar (in the manifest file I write "Main-Class: admin"), and if I launch the application with another batch file:
    echo off
    cls
    java -classpath C:\jdk1.3.1_02\lib\comm.jar -jar hyper.jar
    The application starts, but the interpreter java says to me:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/comm/SerialPortEventListener
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    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)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at hyper.loadModuli_comm(hyper.java:142)
    at hyper.setStatus(hyper.java:63)
    at admin.main(admin.java:205)
    why, the interpreter java, can't it found javax.comm package?
    thanks.

    Hy,
    I tried to set class-path key in manifest file, but the application doesn't start, and the interpreter java doesn't find admin.class... I believe that I set class-path in incorrect way.
    I write:
    Class-Path: C:\jdk1.3.1_02\lib\comm.jar
    is it ok?
    thanks.

  • Are JDev autogenerated paths needed to create ear, war and jar files ?

    Hi
    We want to create ear, war and jar files from Ant build script generated from JDeveloper 11.1.1.7.
    We also like to use ojdeploy with it.
    In the process of creating build.xml files from projects, we see these paths.
    We also have standalone Weblogic installed with ADF runtime 11.1.1.7
    Questions:
    1- Do we need these path ids to generate ear, jar, war files properly and then deploy the ear to our standalone Weblogic so that our webapp can run ok ?
    2- Why are they generated, if they are not needed
    From research, it appears that we don't need these paths except to keep ant targets of init, compile, exec etc with ojdeploy.
    3- Is that true ?
    We are afraid that because no paths are listed in the build.xml, then when we deploy the ear app, it cant use the ADF runtime on the standalone WLS.
    Thanks in advance for answering.
    Sincerely
    eg of paths generated below:
      <path id="library.SOA.Designtime"/>
      <path id="library.SOA.Runtime"/>
      <path id="library.BPEL.Runtime"/>
      <path id="library.Mediator.Runtime"/>
      <path id="library.MDS.Runtime">
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.mds_11.1.1/mdsrt.jar"/>
      </path>
      <path id="library.BC4J.Service.Runtime">
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.adf.model_11.1.1/adfbcsvc.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.adf.model_11.1.1/adfbcsvc-share.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/commonj.sdo_2.1.0.jar"/>
        <pathelement location="{oracle.middleware}/modules/org.eclipse.persistence_1.1.0.0_2-1.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.webservices_11.1.1/wsclient.jar"/>
        <pathelement location="{oracle.middleware}/oracle_common/modules/oracle.web-common_11.1.1.jar"/>
      </path>
      <path id="library.TopLink">
        <pathelement location="{oracle.middleware}/modules/com.oracle.toplink_1.0.0.0_11-1-1-5-0.jar"/>
        <pathelement location="{oracle.middleware}/modules/org.eclipse.persistence_1.1.0.0_2-1.jar"/>
        <pathelement location="{oracle.middleware}/modules/com.bea.core.antlr.runtime_2.7.7.jar"/>
        <pathelement location="{oracle.middleware}/modules/javax.persistence_1.0.0.0_2-0-0.jar"/>
      </path>
      <path id="library.Oracle.Rules"/>
      <path id="classpath">
        <path refid="library.SOA.Designtime"/>
        <path refid="library.SOA.Runtime"/>
        <path refid="library.BPEL.Runtime"/>
        <path refid="library.Mediator.Runtime"/>
        <path refid="library.MDS.Runtime"/>
        <path refid="library.BC4J.Service.Runtime"/>
        <path refid="library.TopLink"/>
        <path refid="library.Oracle.Rules"/>
      </path>

    There are two different things here. Using ant to build the class files and then building an ear from the class files and other resources.
    The building part needs the libraries if you use javac as compiler. Building an ear file only needs the path to the jar files which are packed into the ear.
    In this sense you need the pages you see in the build.xml.
    Then Jdev offers another way: ojdeploy. This tool is a Jdev without a gui.
    You can use this tool and build the classes for each project of a workspace and to build build war and ear file. This is just like you click the rebuild button for each project and then the deploy the projects and application. If you use this approach you don't need the generated path ids as the whole build process is done inside Jdev as it's done on your developer pc.
    Timo

  • How to run .class file and .jar file in jdev9i

    I want to run .class file and .jar file in jdev9i,what should I do?
    Also,I want to generate .class file and .jar file in jdev9i,what should i do?

    Add the .class file containing the public static void main(...) method to the project by clicking on the + toolbar button in the navigator, open the project properties and properly set the additional classpath then right click on the .class in the navigator and say run. It should work, I've just tried it.
    Doesn't work for a .jar yet, in JDeveloper 9.0.3 it works both for .class and .jar
    Michel

  • Where to put common classes and jar files

    hi,
    i want to put some classes and jar files in a common folder so that it can be accessed by other applications is there any way doing that.In tomcat server they have common and shared directories once any classes are into that folder they are being accessed easily ,but i am having problems with sun one .
    Regards
    Ameem Sami

    Did you find a solution for this? I'm having the same problem.
    Thanks,
    Tony

  • Protecting jnlp and jar files

    Hi
    I would like to know how to protect the jnlp and jar files against anyone who just types the URL in the browser Address bar.
    Thanks
    Steven

    Haven't tried, but if your jnlp app must check for updates on every startup and your files (both jnlp file and jars) are in a password protected folder (using digest or plain authentication over a SSL connection, for example) then you may be in trouble. Will JWS recognize this situation on an update check and prompt for login/password? (related to web server's folders).
    Regards

  • [svn:bz-trunk] 19596: Add JGroups 2.11.0 GA source and jar files.

    Revision: 19596
    Revision: 19596
    Author:   [email protected]
    Date:     2011-01-05 08:35:22 -0800 (Wed, 05 Jan 2011)
    Log Message:
    Add JGroups 2.11.0 GA source and jar files.  It requires JDK 1.6.x and up.   Currently it can be only used for runtime and can't be used to build the BlazeDS source, which requires JDK 1.5.x.
    Modified Paths:
        blazeds/trunk/resources/clustering/readme.txt
    Added Paths:
        blazeds/trunk/lib/jgroups-2.11.0.GA.jar
        blazeds/trunk/resources/clustering/JGroups-2.11.0.GA.src.zip

    Revision: 19596
    Revision: 19596
    Author:   [email protected]
    Date:     2011-01-05 08:35:22 -0800 (Wed, 05 Jan 2011)
    Log Message:
    Add JGroups 2.11.0 GA source and jar files.  It requires JDK 1.6.x and up.   Currently it can be only used for runtime and can't be used to build the BlazeDS source, which requires JDK 1.5.x.
    Modified Paths:
        blazeds/trunk/resources/clustering/readme.txt
    Added Paths:
        blazeds/trunk/lib/jgroups-2.11.0.GA.jar
        blazeds/trunk/resources/clustering/JGroups-2.11.0.GA.src.zip

  • I18N and jar files

    We have a site fully i18n'd. My question is this: how can we separate the .properties files from the jar file so we do not have to update the jar file for a static text change?
    I've searched the forums and haven't benn able to find a solution.
    Any help would be appreciated.
    Thanks, Joe

    you can put your properties file anywhere in the classpath.
    Most likely you classpath consists of
    - one or more jar file
    - one or more directories
    just move the properties from the jar file into on of the directories (in the proper subdirectory according to the package name of course) and it should work
    regards
    Spieler

  • Moving a functional jsp and jar file to new directory breaks import?

    Simply put - how can I "move" or "copy" a functional JSP directory from the root of my site to a subdirectory
    of the same site and have it continue to work?
    here are the details:
    I have a site where the functional JSP content resides like so ...
    c:\site\itworkshere\thetestfile.jsp
    c:\site\itworkshere\WEB-INF\web.xml
    c:\site\itworkshere\lib\thejarfile.jar
    c:\site\itworkshere\classes\props.properties
    but when I copy the"itworkshere" directory to c:\site\newdirectory\itworkshere
    and try to load thetestfile.jsp page in my browser, I get ...
    thetestfile$jsp.java:6: Package com.corporatename.module.io not found in import.
    I know that the module.io classes are in thejarfile.jar, but for some reason, now that I've put the files
    in a new directory, the import is failing (simple import directive in thetestfile.jsp) And - yes - the .jar
    file is there in the new subdirectory.
    I am a newbie with jsp and just need to copy the files to new location and have them continue to work.
    Do I have to recompile the .jar with some sort of adjustments? I poked around and I don't see any assumptions about the directory structure in the build. The behavior leads me to believe that the build is assuming something
    about its location in the directory tree.
    Hope this question is clear and I appreciate any direction you can provide to steer me where to look/modify
    the necessary changes so I can move the .jsp's and .jar and not break them.

    Thanks for the suggestions and insights. I have made some progress.
    a context path of "/newdirectory/itworkshere" and a docBase of "./newdirectory/itworkshere" has resolved
    the .jsp include problem.
    However this seems a bit counter-intuitive to me considering that the default root context which is "" stands
    at the appBase which in my case is C:\Site. Since the default does not explicitly refer to the "itworkshere" directory,
    I'd expect that the newly added Context element would not have to either ---- BUT --- it does require that I include "itworkshere" in the context path and docBase (where I would expect ./newdirectory would have been sufficient since the default works that way) ... am I missing something?
    Now I havethe next odd behavior - the Servlet which resides in "itworkshere\WEB-INF\lib" is not loading when I put the appropriate URL in --> /newdirectory/itworkshere/DataCrunchingServlet
    I checked the web.xml file and it has the appropriate servlet-name and url-pattern (relative references)
    Furthermore I did a test where I simply rename the original working instance directory and again --- the URL is failing to find the servlet!!! (and yes I stopped/started Tomcat) It is as if the servlet can only be found in the originally installed scenario.
    I am extremely puzzled that the behaviors seem to indicate an assumption about the path structure, but the web.xml file is set up correctly.
    Help help!!! and Thank you.l

  • Java executables and jar files

    I'm new to Java and recently completed a Java training class that involved the creation of a cutomer service application in Microsoft Visual J++. The application ran fine in debug mode. However, no mention was made of how this would be run on a machine without an development tool as J++. How is this done? Can Java programs be compiled into .exe's like C, C++,, abd Visual basic programs? If not, how are the classes called to make use of their code?
    Also, what is a .jar file and how is it used?

    You went to a class and they didn't teach you the answers to these questions? I say go and get your money back: you we're ripped off.
    1) Yes you can turn your java code into an .exe but that would be pointless as java was designed to be "platform independant" and this violates that principle.
    2) jar files are zip files for all intents and purposes. They contain your 'compiled' java byte code.
    3) Microsoft does not support J++ nor does it ship java with its browser anymore so I suggest you download java from this website and use the real thing.

  • Classpath for jar files?

    Hi all,
    i am trying to run a standalone java program using JRC through command promt.
    my problem is i am importing few classes from jar files into my java class. but its not getting imported.
    how to resolve it?

    Hi Saravana
    You can use batch file to run your standalone java program.
    The contents of the batch file would be as follows:
    @echo off
    if "%OS%" == "Windows_NT" setlocal
    rem
    rem Sets the CLASSPATH environment variable to include all JAR files
    rem required for the JRC then compiles and jars Java file(s).
    rem
    rem Edit the environment variable BOBJ_JAVA_LIB to point to the
    rem location where you have the JRC jar files.
    rem
    rem Make sure to define any other required libraries in the environment
    rem variable CLASSPATH.
    rem
    rem Make sure you have defined the environment variable JAVA_HOME
    rem
    set BOBJ_JAVA_LIB=c:\Program Files\Business Objects\Common\3.5\java\lib
    set CURRENT_DIR=%cd%
    echo Using JAVA_HOME: %JAVA_HOME%
    echo Using CURRENT_DIR: %CURRENT_DIR%
    set RUNJAVA="%JAVAHOME%/bin/java"
    set RUNJAVAC="%JAVAHOME%/bin/javac"
    set RUNJAR="%JAVAHOME%/bin/jar"
    set CLASSPATH=%BOBJ_JAVA_LIB%\ReportViewer.jar;%BOBJ_JAVA_LIB%\ReportPrinter.jar;%BOBJ_JAVA_LIB%\CrystalCommon.jar;%BOBJ_JAVA_LIB%\CrystalDatabaseConnectors.jar;%BOBJ_JAVA_LIB%\CrystalReportingCommon.jar;%BOBJ_JAVA_LIB%\CrystalFormulas.jar;%BOBJ_JAVA_LIB%\CrystalQueryEngine.jar;%BOBJ_JAVA_LIB%\CrystalReportEngine.jar;%BOBJ_JAVA_LIB%\keycodeDecoder.jar;%BOBJ_JAVA_LIB%\MetafileRenderer.jar;%BOBJ_JAVA_LIB%\rpoifs.jar;%BOBJ_JAVA_LIB%\jrcerom.jar;%BOBJ_JAVA_LIB%\jrcadapter.jar;%BOBJ_JAVA_LIB%\rascore.jar;%BOBJ_JAVA_LIB%\rasapp.jar;%BOBJ_JAVA_LIB%\Serialization.jar;%BOBJ_JAVA_LIB%\external\log4j.jar;%BOBJ_JAVA_LIB%\external\icu4j.jar;%BOBJ_JAVA_LIB%\external\Concurrent.jar;%BOBJ_JAVA_LIB%\external\xercesImpl.jar;%BOBJ_JAVA_LIB%\external\xml-apis.jar;%BOBJ_JAVA_LIB%\CrystalCharting.jar;%BOBJ_JAVA_LIB%\CrystalContentModels.jar;%BOBJ_JAVA_LIB%\CrystalExporters.jar;%BOBJ_JAVA_LIB%\CrystalExportingBase.jar;%CURRENT_DIR%;%CLASSPATH%
    %_RUNJAVAC% -classpath "%CLASSPATH%" *.java
    %_RUNJAVA% -classpath "%CLASSPATH%" HelloWorldSwing
    // HelloWorldSwing is the name of your .java file
    Make sure you have all the jar files in the lib directory.
    Hope this helps you.
    Thanks
    Soni

  • .properties and jar file

    Anyone, Is there a way to separate my .properties files from the jar. Everytime we want to make a simple text change we need to redeploy a new jar. I've tried taking the .properties files out of the jar and placing them in the class path, but I get this:
    Can't find resource for base name com.dynamex.dxnow.labelsBundle, locale en_US
    normally our .properties files are in: com.dynamex.dxnow.dxnow4
    where dxnow4 is the jar name
    We're running Apache
    Deveolpment environment JDeveloper
    Any help would be appreciated,
    Joe

    I've tried taking the .properties files out of the jar and placing them in the class path,<<Sorry this is not of much help, but putting the properties file in the classpath should work. I've done that myself. If the properties file is in the classpath before the jar file, it will be used instead of the properties file in the jar file. So, maybe the properties file is in a package and the directory containing the package is not on the classpath?

  • Classpath in JAR file

    I have packed my stand alone app, which is using JAVA Mail API in one JAR file (myapp.jar).
    Since JAVA Mail requires 2 seperate jar files, I created a lib dir within the jar that contains all required jar files.
    How do I add the lib directory inside the jar to my classpath ?
    Just adding myapp.jar to the classpath is not enough.
    I also tried to put Class-Path into my Manifest.mf file inside the jar
    which did not help. What dir does the manifest.mf file go inside the jar ? How would my Class-Path value have to look ? Maybe I did something wrong there ? Or is the whole thing just not possible and I have to deliver all other jar files seperate :(((((((

    Yes that is exactly how it looks. And if it looks like
    that, the
    lib dir has to be outside the jar file. The '.' is the
    same dir as the jar dir. Was your reply a guess or did
    you actually manage to do something like that ?I thought I had this working myself. After many iterations, I was able to run the jar files I was creating. Right after I figured it all out, your querry came up.
    But, just last night, I realized something was wrong. I tested this structure on both machines I write code on (one Linux, one Win2k) and it worked on both. Finally, I wanted to test on my 'depolyment' machine, a Win2k laptop I rarely write code with, and nothing workded. I was getting the same classdef not found errors you were.
    I finally realized, as you mention, it worked on my other machines because the "lib/some.jar" structure existed on the disk. Thus, the jar files were in the larger one, but those weren't being used. Argh. Of course the laptop doesn't have those jars somewhere else. So nothing worked.
    Guess this was a case of the blind leading the blind. Sorry! I've had to resort to putting out both jars and doing some rearranging of internal packages to get everything to work from a jar file. I need to have all this done for a trade show next week (Java on Wall Street, anyone?), so it works 'well-enough' right now. Hopefully I'll get back to this and find the proper solution after the show.

  • Problems with ClassLoader and Jar-Files

    1. I'm not good in englisch (writing).
    2. I have the problem, that i want to load a object from an application in Jar-File A out of the Jar-File B. I set the CLASSPATH for B with System.setProperty("java.class.path", <ClassPath>); . Then i tried to get the Class-object from a class of B. I do it with getClass().getForName("package.Name");.
    But everytime i get a ClassNotFoundException. Where is the Error? Or how can i load a class out of a Jar-File and get an instance? I hope you can help me..
    Tobain

    The error is that classes are loaded from the classpath as it existed when the program started. Changing the system property that was copied from the classpath has no effect, as you have seen. I have heard that you can write your own ClassLoader if you want to load classes from arbitrary locations, but I do not know how to do that myself.

Maybe you are looking for

  • IMac Screen Issues

    I recently had my iMac serviced at the closest Apple Store... an hours drive for me. It had a hazy discoloration in the upper left and right corners of the screen. The tech told me the solution was to have the screen replaced...for $600! Fortunately,

  • Page order

    I saved a 2 page Word doc as PDF and it shows back to front on the screen.  How do I change the page order?

  • FCKR - Online Cashed Checks

    Hi All, I am trying to update check encashment details in the check register through the online program FCKR. The file received from the bank is mapped as per the SAP standard, but when trying to update the details from FCKR, there is a message Text

  • Need to find mail on TIme Machine backup

    My wife uses our POP mail account from AT&T. She had a couple of E-mails flagged in OSX mail and they disappeard earlier this week. I am backing up my HD with time machine. How can I go back in time, to find the E-mails that have disappeard? Thanks i

  • Re-installation "best practices"?

    well..... Bridge has gone bad..... and I find that I need to reinstall the entire suite to install Bridge..... (feel free to fill in the blanks) Does a new installation uninstall before installing?  are there any best practices for a do-over? thanks