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.

Similar Messages

  • 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

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

  • 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

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

  • Server won't start and JAR files

    My application uses external classes (quartz, jersey, jackson) and I included all the jar files containing the external classes in the WEB-INF\lib directory of the EAR file already. I deployed it to WLS 10.3.5 on windows but when I tried to start it up, it failed to start up.
    I copied all those jar files and put them in the <domain>\lib directory and add in the classpath section on the ServerStart tab of the server then it started up.
    I thought if you include those jar files in the WEB-INF\lib of the EAR file then you don't need to put them in the <domain>\lib and specify in the classpath section?
    Do you have any ideas?

    Sorry, I meant WEB-INF\lib in the WAR file inside my EAR.
    I put all the jar files in the WEB-INF\lib of the WAR file but it still does not work. I have to specify them in the classpaths and put the jar files in the domains\domain\lib directory
    I thought if you put it in the WEB-INF\lib then you don't have to put them in the classpath.
    Am I right?

  • 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

  • The system doesn´t let me change the dock and .jar files

    Dear professionals,
    since a couple of days I come across with a weird problem:
    I am logged in as admin but the system doesn`t perform several modifications:
    such as:
    if I remove a broken link from the dock (grey questionmark) and replace it with a new link to the new app the next session everything is unchanged and the questionmark is back.
    if I want firefox not to play quicktime and try to change the preferences it flips back immediately
    if I want to open Cocktail to schek something it does not accept me as admin - whereas the systems calls me admin.
    maybe the futile attempt to alter the minecraft.jar has the same reason.
    At many files the file info shows a strange entry at the botten where the sharing/permission are listed: Name is "Laden..." meanig "Loading..." with the dots and as symbol a grey person with tiny questionmark; permission is "read only"
    History:
    Till now I never used a password and logged in automatical as admin
    I upgraded to Lion
    I installed a second account to have a workspace not as admin
    I gave a password to the admin account
    I got nuts with the second account as I couldn´t change the preferences of firefox and delete files and so on
    I gave administration rights to the second account to customize the workspace
    I realized the problems with the admin account - changes where ignored/forgotten by the system w/o warnings
    I deleted the second account as it seemed to cause the trouble
    I repaired the rights in the admin account
    I repaired the HD with HD recovery
    I try to check the system with cocktail but cocktail tells me the password is not sufficient - it opens the app but it refuses any modifications
    I switched to manual login
    System tells me that the keychain.login does not accept the password
    I set the password for keychain also
    keychain first aid tells me the password does not work ?
    I removed the password from admin account
    I removed the password from keychain first aid is happy
    Repair rights does not find any trouble
    Cocktail does not accept me anyway anymore, without password (as i logged in) or the former passwords- it blocks at all.
    And all the other stuff listed at the beginning drives me crazy
    File Info window tells me i have adapted rights- whatever it means, as i am listed with full read/write rights
    now I am stunned.
    I would like to use my Installation disk to repair anything - but as it is not the lion system I am afraid to cause more trouble.
    Does anyone have a clue?
    And sorry for the strange text- english is not my native language
    And, btw, is netinfo manager removed by lion? it does not appear on my volume.
    Thanks for Your help
    Bernhard

    Repairing the permissions of a home folder in Lion is a complicated procedure. I don’t know of a simpler one that always works.
    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the page that opens.
    Drag or copy – do not type – the following line into the Terminal window, then press return:
    chmod -R -N ~
    The command will take a noticeable amount of time to run. When a new line ending in a dollar sign ($) appears below what you entered, it’s done. You may see a few error messages about an “invalid argument” while the command is running. You can ignore those. If you get an error message with the words “Permission denied,” enter this:
    sudo !!
    You'll be prompted for your login password, which won't be displayed when you type it. You may get a one-time warning not to screw up.
    Next, boot from your recovery partition by holding down the key combination command-R at startup. Release the keys when you see a gray screen with a spinning dial.
    When the recovery desktop appears, select Utilities ▹ Terminal from the menu bar.
    In the Terminal window, enter “resetpassword” (without the quotes) and press return. A Reset Password window opens.
    Select your boot volume if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select  ▹ Restart from the menu bar.

Maybe you are looking for