Packages to CLASSPATH's??

Is there a difference in adding a package to the CLASSPATH as opposed to simply adding folders etc.
I keep getting the "NoClassDefFoundError:lava/io/URLInputStream", even though both C:\lava and C:\lava\io are in my CLASSPATH
Any Ideas?
ahhfor

Hi. Since the package lava/io/URLInputStream is in C, try setting the classpath to just c:\
I don't think there's any difference in setting the classpath to point to folders or jar files, they work just the same.
Hope that helps.
Is there a difference in adding a package to the
CLASSPATH as opposed to simply adding folders etc.
I keep getting the
"NoClassDefFoundError:lava/io/URLInputStream", even
though both C:\lava and C:\lava\io are in my
CLASSPATH
Any Ideas?
ahhfor

Similar Messages

  • How to set packages and classpath

    Hi,
    I want to know about packages and classpath. I have these questions
    1, If I put a class in a package(work.util) is it necessary to put the java file in the same directory/directory hierarchy as mentioned in the package declaration. I have to compile this class, run it from main method and must be able for other classes to import.
    2. If a package have subpackages(work.util.db) do I have to set the classpath to subdirectory also to run that class.
    3. If a class is in package is it possible to run the class without prefixing the package name. I need to do this in the text editor so that I can run any program by pressing a hot key.
    rgds
    Antony Paul

    1, If I put a class in a package(work.util) is it
    necessary to put the java file in the same
    directory/directory hierarchy as mentioned in the
    package declaration.Strictly speaking, this isn't covered by the spec - it depends on what compiler and ClassLoader you are using. If you're using Sun's JDK, then yes.
    2. If a package have subpackages(work.util.db) do I
    have to set the classpath to subdirectory also to run
    that class. No. You should add the directory above work/util/db to your classpath. You should not add work, or work/util or work/util/db.
    E.g., if your Java files are in C:/MyProject/JavaSrc/work/util/db, and the package name is work.util.db, then you should have C:/MyProject/JavaSrc on your classpath (or have "." (dot) on your classpath, and compile and run from that same directory).
    3. If a class is in package is it possible to run the
    class without prefixing the package name. I need to do
    this in the text editor so that I can run any program
    by pressing a hot key.If you mean "in order to run work.util.db.Main do I need to type java work.util.db.Main, or just java Main", then you do indeed need the fully qualified class name (otherwise, how would the runtime environment know which class you mean? - there could be any number of classes called Main in any class, and it would have to search every directory and subdirectory on your classpath to find them.

  • Package and CLASSPATH

    Hi,
    I have a hard time understanding the package and CLASSPATH. I want to have a solid understanding of it. I read some tutorials online but didn't make me fully understand. How does declaring a package effect the CLASSPATH? Say I have following:
    (This is from one of the tutorial- http://home.cogeco.ca/~ve3ll/jatutor4.htm)
    C:\myclasses\world\moon\HelloMoon.java
    C:\myclasses\world\HelloWorld.java
    HelloMoon.java is defined as
    package world.moon;
    public class HelloMoon {
    private String holeName = "rabbit hole";
    public String getHoleName() {
    return holeName;
    public void setHole(String holeName) {
    this.holeName = holeName;
    public static void main(String[] args){
         HelloMoon moon = new HelloMoon();
         System.out.println(moon.getHoleName());
    HelloWorld is defined as
    package world;
    public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello World");
    if the CLASSPATH is set : set CLASSPATH=.;C:\myclasses;
    Once the CLASSPATH has been set (and compiled .java file); it can be called using the following from any path of directory:
    java world.HelloWorld
    java world.moon.HelloMoon
    But it does not explain the details why it works this way. Also, if I want to run it without using "world" prefix to run HelloWorld, what do I need to set up?
    also for the HelloMoon?
    When I tried running those classes by going to an appropriate directory, I got the noClassDefFound (using command like "java HelloWorld" or java "HelloMoon").
    Thanks in advance...

    [Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath]
    [How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]
    [Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]
    [Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]
    [Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]
    java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
    javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

  • Problem in the package or classpath

    Hello every body
    I want to add a module at "jhove" which is open source: http://hul.harvard.edu/jhove/index.html
    When I launch jhove like this: ./jhove -k file.pdf, it shows me more informations about this pdf.
    I want that it re-knows me anathor type of file.(warc format)
    Then I have to write a new module.
    I try to do it following the link: http://hul.harvard.edu/jhove/writingamodule.html
    I added my java code in :/home/jhove/classes/edu/harvard/hul/ois/jhove/module/Project/
    The compilation works well.
    I add : EXTRA_JARS=/jhove/classes/edu/harvard/hul/ois/jhove/module/Project/WarcModule.jar
    At the file: jhove.tmpl
    I also add this code at jhove.conf like they montionned in document:
    <module>
    <class>WarcModule</class>
    </module>
    I also try with this solution:
    <module>
    <class>edu.harvard.hul.ois.jhove.module.Project.MonModule</class>
    </module>
    But I have this error:
    edu.harvard.hul.ois.jhove.JhoveException: cannot instantiate module: WarcModule
    at edu.harvard.hul.ois.jhove.JhoveBase.init(Unknown Source)
    at Jhove.main(Unknown Source)
    I think that is problem in the classpath.
    There is my code:
    package edu.harvard.hul.ois.jhove.module.Project;
    import java.io.File; 
    import java.util.*;
    import java.io.*;
    import edu.harvard.hul.ois.jhove.*;
    import edu.harvard.hul.ois.jhove.ModuleBase;
    import edu.harvard.hul.ois.jhove.RepInfo;
    import org.archive.io.warc.*;
    public class MonModule extends ModuleBase
             private static final String NAME = "Warc-hul";
             private static final String RELEASE = "1.7";
             private static final int [] DATE = {2008, 9, 23};
             private static final String [] FORMAT = { "warc"};
             private static final String COVERAGE =
                 "PDF 1.0-1.6; PDF/X-1 (ISO 15930-1:2001), X-1a (ISO 15930-4:2003), " +
              "X-2 (ISO 15930-5:2003), and X-3 (ISO 15930-6:2003); Tagged PDF; " +
              "Linearized PDF; PDF/A (ISO/CD 19005-1)";
             private static final String [] MIMETYPE = {"application/warc"};
             private static final String WELLFORMED = "A PDF file is " +
                 "well-formed if it meets the criteria defined in Chapter " +
                 "3 of the PDF Reference 1.6 (5th edition, 2004)";
             private static final String VALIDITY = null;
             private static final String REPINFO = null;
             private static final String NOTE = "This module does *not* validate " +
              "data within content streams (including operators) or encrypted data";
             private static final String RIGHTS = "Copyright 2003-2007 by JSTOR and " +
              "the President and Fellows of Harvard College. " +
              "Released under the GNU Lesser General Public License.";
             private static final String ENCRYPTED = "<May be encrypted>";
    protected MonModule(String NAME, String RELEASE, int[] DATE, String[] FORMAT, String COVERAGE, String[] MIMETYPE, String WELLFORMED, String VALIDITY, String REPINFO, String NOTE, String RIGHTS, boolean x)
             super  (NAME, RELEASE, DATE, FORMAT, COVERAGE, MIMETYPE, WELLFORMED,VALIDITY, REPINFO, NOTE, RIGHTS, true);
    * PRIVATE INSTANCE FIELDS.
    /* First 6 bytes of file */
    protected byte _sig[];
    /* Checksummer object */
    protected Checksummer _ckSummer;
    /* XMP property */
    protected Property _xmpProp;
    /* Input stream wrapper which handles checksums */
    protected ChecksumInputStream _cstream;
    /* Data input stream wrapped around _cstream */
    protected DataInputStream _dstream;
    /* Flag for presence of global color table */
    protected boolean _globalColorTableFlag;
    /* Size of global color table */
    protected int _globalColorTableSize;
    /* Count of graphic control extensions preceding
    * something to modify */
    protected int _gceCounter;
    /* Top-level metadata property */
    protected Property _metadata;
    /* Blocks list property */
    protected List _blocksList;
    /* Total count of graphic and plain text extension blocks */
    protected int _numGraphicBlocks;
    public void checkSignatures (File file,  InputStream stream, RepInfo info)
    throws IOException
    int sigBytes[] = { 'W', 'A', 'R', 'C'};
    int i;
    int ch;
    try {
        _dstream = null;
        _dstream = getBufferedDataStream (stream, _je != null ?
                    _je.getBufferSize () : 0);
        for (i = 0; i < 4; i++) {
            ch = readUnsignedByte(_dstream, this);
            if (ch != sigBytes) {
    info.setWellFormed (false);
    return;
    info.setModule (this);
    info.setFormat (_format[0]);
    info.setMimeType (_mimeType[0]);
    info.setSigMatch(_name);
    catch (Exception e) {
    // Reading a very short file may take us here.
    info.setWellFormed (false);
    return;
    Please can any one help me.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Daniel, not sure if everything is clear now, but the way you are validating a WARC file is seriously flawed! I strongly suggest you use an existing WARC tool to do the actual parsing/validating.
    I've seen more and more people on JHove's mailing list posting problems on how to create their own modules, so I decided to write a small how-to-write-your-own-module-guide.
    Perhaps you'd like to give it a shot. I'll also post it on the mailing list.
    ================================================================================
    This is a step-by-step tutorial that will enable you to compile and run a
    custom made module for Harvard's idetification tool JHove [1]. This is not
    a tutorial on Java programming! For a thorough explanation of this tool and
    extensive documentation, please see:
    [http://hul.harvard.edu/jhove/documentation.html]
    ================================================================================
    = Setp 1 =
    Download and unzip JHove 1.1f [2]. The unzipped folder will be called
    JHOVE_HOME from now on.
    ================================================================================
    = Step 2 =
    In this example I will construct a very elementary ARC module and will be using
    Heritrix' [3] ARCUtils class, so download Heritrix 1.14 [4] and unzip it. After
    unzipping, locate the file 'heritrix-1.14.1.jar' (it might be a different
    version) and place it in the directory 'JHOVE_HOME/bin'.
    ================================================================================
    = Step 3 =
    Create a folder 'JHOVE_HOME/bin/test' and create a new file in it called
    'ArcModule.java'. Paste the following contents in that file:
    package test;
    import java.io.IOException;
    import java.io.InputStream;
    import edu.harvard.hul.ois.jhove.ModuleBase;
    import edu.harvard.hul.ois.jhove.RepInfo;
    import org.archive.io.arc.ARCUtils;
    public class ArcModule extends ModuleBase {
        private static final String NAME = "ARC-hul";
        private static final String RELEASE = "0.1";
        private static final int[] DATE = {2008, 11, 11};
        private static final String[] FORMAT = {"ARC"};
        private static final String COVERAGE = null;
        private static final String[] MIMETYPE = {"application/arc"};
        private static final String WELLFORMED = "...";
        private static final String VALIDITY = null;
        private static final String REPINFO = "...";
        private static final String NOTE = null;
        private static final String RIGHTS = "GNU LGPL";
        public ArcModule() {
            super (NAME, RELEASE, DATE, FORMAT, COVERAGE, MIMETYPE, WELLFORMED,
                    VALIDITY, REPINFO, NOTE, RIGHTS, false);
            // Optionally set some Agent information: see the other Modules how
            // this can be done.
        @Override
        public int parse(InputStream stream, RepInfo info, int parseIndex) {
            info.setModule(this);
            boolean wellFormed = false;
            try {
                if(ARCUtils.testCompressedARCStream(stream)) {
                    wellFormed = true;
            } catch (IOException e) {
                e.printStackTrace();
            info.setWellFormed(wellFormed);
            return 0;
    }================================================================================
    = Step 4 =
    Compile this ArcModule by opening a shell (command prompt) and cd-ing to
    'JHOVE_HOME/bin' and executing the following command:
    *nix & Mac OS:
    javac -cp .:JhoveApp.jar:heritrix-1.14.1.jar test/ArcModule.javaWindows:
    javac -cp .;JhoveApp.jar;heritrix-1.14.1.jar test\ArcModule.java
    (Note, if you're using JDK 1.4, replace '-cp' with '-classpath')
    You shouldn't get any messages if all goes well.
    ================================================================================
    = Step 5 =
    Open the file 'JHOVE_HOME/conf/jhove.conf' and add the following right beneath
    the line <bufferSize>?????</bufferSize>, where ????? is a number:
    <module>
      <class>test.ArcModule</class>
    </module>Save the file.
    ================================================================================
    = Step 6 =
    Create a folder called 'JHOVE_HOME/arcs' and copy two compressed ARC files in
    them. If you don't have any compressed ARC files laying around, you can
    download two small [5]. The file 'A.arc.gz' is a valid compressed ARC file,
    while 'B.arc.gz' is the same as 'A.arc.gz' but I removed the ARC-header from
    the latter, making it an invalid ARC file.
    ================================================================================
    = Step 7 =
    Open a shell, cd to 'JHOVE_HOME/bin' and execute the following command:
    *nix & Mac OS:
    java -cp .:JhoveApp.jar:heritrix-1.14.1.jar Jhove -c ../conf/jhove.conf -m ARC-hul ../arcsWindows:
    java -cp .;JhoveApp.jar;heritrix-1.14.1.jar Jhove -c ..\conf\jhove.conf -m ARC-hul ..\arcsWhich will cause JHove to scan everything that is in 'JHOVE_HOME/arcs' folder
    and throws it through your newly create ArcModule. The output will be as
    follows:
    Jhove (Rel. 1.1, 2008-02-21)
    Date: 2008-11-14 22:29:51 CET
    RepresentationInformation: .../jhove/arcs/A.arc.gz
      ReportingModule: ARC-hul, Rel. 0.1 (2008-11-11)
      LastModified: 2008-08-24 20:23:20 CEST
      Size: 130870
      Status: Well-Formed and valid
    RepresentationInformation: .../jhove/arcs/B.arc.gz
      ReportingModule: ARC-hul, Rel. 0.1 (2008-11-11)
      LastModified: 2008-11-14 21:53:15 CET
      Size: 116136
      Status: Not well-formedWhich is the expected result: A is valid and B is not.
    ================================================================================
    = Final remarks =
    As I said, this is not a programming tutorial, nor is it the best way to
    validate ARC files: more meta data should be extracted from the file. But I
    leave that for you. This was only a guide to show you how to get started on
    writing and running your own modules. You can have a look at the source
    of the existing modules to see the "best practices" w.r.t. writing a module.
    Best of luck!
    Regards,
    Bart.
    ================================================================================
    = References =
    [1] [http://hul.harvard.edu]
    [2] [http://hul.harvard.edu/jhove/download.html]
    [3] [http://crawler.archive.org]
    [4] [http://sourceforge.net/project/showfiles.php?group_id=73833&package_id=73980]
    [5] [http://iruimte.nl/arcs]

  • Adding packages and classpath

    Hi there all,
    Having finished by first Java application for work, I'm trying to create an executable jar file for it.
    The current directory structure is: -
    +---- programs
    |        |
    |        |---- GateKeeper
    |
    |---- commonfilesThe commonfiles directory contains the packages my program uses. I usually run the program via a batch file which is in the GateKeeper directory using: -
    C:\j2sdk1.4.2_04\bin\java -classpath .;h:\Java\commonfiles\ojdbc14.jar;h:\Java GateKeeper
    I have read the jar file tutorial and have created my jar file by using: -
    jar cf GateKeeper.jar programs commonfiles
    I'm now trying to set the Main-Class within the jar file. So I have tried this: -
    jar cmf Main-Class: programs/GateKeeper/GateKeeper GateKeeper.jar
    However, I keep getting this error: -
    H:\Java\JarTemp>jar cmf Main-Class: programs\GateKeeper\GateKeeper GateKeeper.jar
    java.io.FileNotFoundException: Main-Class: (The system cannot find the file spec
    ified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at sun.tools.jar.Main.run(Main.java:123)
    at sun.tools.jar.Main.main(Main.java:904)
    H:\Java\JarTemp>
    This is my first time trying to deploy something that I've made, so a little patience wouldn't go amiss here. :) I also need to somehow add the commonfiles directory to the internal classpath of the jar file so that the application can find my packages (which used to happen by setting the classpath on execution).
    Thanks for any help.

    Heh.......this is turning into a bit of a running commentary. Perhaps I can sell the movie rights "Newbie: When Jars Go Bad". :)
    Anyway.....onward.
    Got the thing to execute (sort of) by just having commonfiles as a directory and the rest as seperate class files. I've got a text file containing the manifest (callded "manifest" now)
    Main-Class: GateKeeper
    Class-Path: commonfiles\ojdbc14.jar commonfiles .
    I've created the Jar file using: -
    jar cvmf manifest GateKeeper.jar commonfiles images GateKeeper.class GateKeeperFrame$1.class GateKeeperFrame$MainAction.class GateKeeperFrame$MainButtonListener.class GateKeeperFrame.class LoginFrame$DataSource.class LoginFrame.class UsersDataModel.class
    ...which is basically just a bunch of classes.
    I can now execute the Jar file using "java -jar GateKeeper.jar".....all well and good. However, I now get this error.: -
    Exception in thread "main" java.lang.NoSuchMethodError
    at GateKeeper.main(GateKeeper.java:25)
    ...which, in my "main" method is this line: -
    Point centreScreen = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
    Any particular reason that its barfing here? Remember I can run this application fine when its not jar'ed.

  • Packages..CLASSPATH ?!!

    HI,
    I'm quite a newbie to Java.Could anyone give me any link to a web page that gives me a detailed explanation on Packages and the Classpath environment variable.
    I'm getting some compile-time errors while working with Packages (probably because the classpath isn't configured properly).

    I found a good discussion by searching at the javaranch.com site. As a newbie also I found that the key point about packages was in the practical application -- when you compile a package you have to compile from the parent directory, not the directory which constitutes the package. So the statement at the command line is:
    javac .\<package_name>\<src_files>
    Then to run the app, if your class has a main method:
    java <package_name>.<class_name>
    Hope this helps.

  • Setting multiple packages to Classpath

    Hi Friends,
    I want set to a directory to classpath which has multiple packages like D:\CED_Siebel_13092007\temp\cmwCallImplLib\org\apache\axis\client
    D:\CED_Siebel_13092007\temp\cmwCallImplLib\com\bofa\crme\ccs\proxy
    Means in directory path D:\CED_Siebel_13092007\temp\cmwCallImplLib
    I have 1.)org.apche.axis.client(Listof classfiles)
    2.)com.bofa.crme.ccs.proxy.(Listof classfiles)
    How to make compiler recognise these classfiles?
    Because I am weblogic server to deploya war file which is making a reference to these class files.
    Though I need to have basic knowledge abt CLASSPATH,
    Please Help me Friends,
    Thanks in Advance...

    "D:\CED_Siebel_13092007\temp\cmwCallImplLib"
    This path should be part of your CLASSPATH.

  • Help with packages and classpath

    Heya,
    first off, i use textpad to compile my java, i don't do it via the command line.
    my problem is faily simple, i think. i've got a main class and i'd like it to import a custom class from a subdir.
    Main class is in
    C:\Documents and Settings\David\Desktop\java\test_gen.java
    I would like it to import
    C:\Documents and Settings\David\Desktop\java\obj_data\objects.java
    I understand that I have to declare objects.java to be a part of a package, so i head the code with: package obj_data; as i understand it, the directory in which the package to be imported resides in will be named the same as the package.
    When i import my package into test_gen.java, i import obj_data as follows:
    import obj_data.*;
    this should import objects.class and any other classes in the same directory. also import obj_data.objects.*; could be used.
    Anyway, thats my understanding of how you set up the class and package; i also understand that when the java file compiles the compiler looks at the directoy(s) indicated in the class path for the classes to import. that in mind i tried to add:
    C:\Documents and Settings\David\Desktop\java\obj_data\
    to my classpath. i did this via dos, javac -classpath "C:\Documents and Settings\David\Desktop\java\obj_data\"
    i got no error messages, so i assume it worked. however when i try to compile the main java (test_gen) i get-
    package packages does not exist
    import packages.*;
    ^
    1 error
    Tool completed with exit code 1
    can anyone give me some help please?

    This is a minimal explanation of packages.
    Assume that your programs are part of a package named myapp, which is specified by this first line in each source file:
    package myapp;
    Also assume that directory (C:\java\work\) is listed in the CLASSPATH list of directories.
    Also assume that all your source files reside in this directory structure: C:\java\work\myapp\
    Then a statement to compile your source file named aProgram.java is:
    C:\java\work\>javac myapp\aProgram.java
    Explanation:
    Compiling
    A class is in a package if there is a package statement at the top of the class.
    The source file needs to be in a subdirectory structure. The subdirectory structure must match the package statement. The top subdirectory must be in the classpath directory.
    So, you generate a directory structure C:\java\work\myapp\ which is the [classpath directory + the package subdirectory structure], and place aProgram.java in it.
    Then from the classpath directory (C:\java\work\) use the command: javac myapp\aProgram.java
    Running
    Compiling creates a file, aProgram.class in the myapp directory.
    (The following is where people tend to get lost.)
    The correct name now, as far as java is concerned, is the combination of package name and class name: myapp.aProgram (note I omit the .class) If you don't use this name, java will complain that it can't find the class.
    To run a class that's NOT part of a package, you use the command: java SomeFile (assuming that SomeFile.class is in a directory that's listed in the classpath)
    To run a class that IS part of a package, you use the command java myapp.aProgram (Note that this is analogous to the command for a class not in a package, you just use the fully qualified name)

  • Running package using -classpath switch

    Hi,
    I have made a program and specified the package key word at the top of prog and then storing it in the package directory. I have created the class file but when I try to run the program from D:\> , I am getting errors.
    package MyPack;
    class Balance{
       String  name;
       double  bal;
       Balance  (String n, double b) {
          name=n;
          bal=b;
      void  show ( ) {
        if(bal < 0)
           System.out.println("--> ");
        System.out.println(name + ": $" + bal);
    class AccountBalance{
       public  static  void  main (String  args[ ]) {
       Balance  current [ ] = new Balance[3];
       current[0]=new Balance("K. J. Fielding", 123.23);
       current[1]=new Balance("Will Tell", 157.02);
       current[2]=new Balance("Tom jackson",-12.33);
      for (int i=0; i< 3; i++) current.show ( );
    class is stored in the following directory:
    D:\javaprogs\misc\Packages\MyPack
    D:\>java -classpath D:\javaprogs\misc\Packages AccountBalance
    Exception in thread "main" java.lang.NoClassDefFoundError: AccountBalance
    D:\>java -classpath D:\javaprogs\misc\Packages\ AccountBalance
    Exception in thread "main" java.lang.NoClassDefFoundError: AccountBalance
    D:\>
    What's the prob with the statements I have written for running the program?
    Zulfi

    java -classpath D:\javaprogs\misc\Packages MyPack.AccountBalance Also, it's customary in Java to name packages in all lowercase. So MyPack would be mypack.

  • Set package in classpath?

    Hi, I am wondering how to set the jar file containing the package (org.ccil.cowan.sax.*) in my classpath ? Do I need to download anything first? HELP!!!!

    Setting the Classpath:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/classpath.html
    [NOTE: always start your classpath with ".;" which means the current directory]
    How Classes are Found:
    http://java.sun.com/j2se/1.4.2/docs/tooldocs/findingclasses.html
    Of course, the jar must exist somewhere in your computer file system; its location and name (ie, the full path spec) is what you use to create the classpath entry.

  • How to Include libraries (Jar's/Packages/ClassNotFoundException/Classpath)

    Ive spent hours looking for a solution, So maby i making a simple human error which i cant find.
    Im unfamiliar with using packages.
    I have created a program that use the JDBC libary. However i need to distribute this program and keep getting a ClassNotFoundException which is throw by:
    String s = "com.mysql.jdbc.Driver";
    Class.forName(s);I would like to have the "mysql-connector-java-bin.jar" file inside my main jar file However I think this may be very complex so i assume it would be easier to have it in the same directory as the main jar file.
    I create my main jar file with:
    jar cmf mainClass.txt Main.jar *.class mysql-connector-java-bin.jarI also jarsigner but i wouldn't expect this to case this problem.
    mainClass.txt
    Main-Class: MyClassFile
    Class-Path: mysql-connector-java-bin.jar
    Sealed: trueAny ideas what im doing wrong? or How i could solve this problem?
    Do i need to write a program which installs the JDBC on their system?
    Is there an easy solution?
    Any advice would be greatly appriacted.
    Thanks,

    ty for the reply
    I now create my jar file with:
    jar cmf mainClass.txt Main.jar *.classand the "mysql-connector-java-bin.jar" is still in same directory as my main.jar file
    Ive also replaced the "mysql-connector-java-bin.jar" to make sure it hasnt been corrupted somehow.
    However i still get the same error.
    the stackTrace is:
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
            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 SQLConnection.<init>(SQLConnection.java:18)SQLConnection a class i have created.and the lines 17 and 18 are posted in my first post.
    Anyideas?

  • I cant access my custom library. "error:Package X does not exist".

    First of all, there is nothing wrong with my sourcecode. I've checked it and it runs fine when my client class and the rest of the classes is thrown into the same directory together.
    Thing is, I have a lot of reusable code,which works, and I have to my best ability followed guidelines on the net how to put them into a liberary and use the import statement in the client to make use of that liberary. My client class still cant find the library, and yes it has the proper import statement. It just tells me that the package does not exist. I've tried to compress the library to a jarfile:
    jar cf mittBibliotek.jar *
    , and I've tried treating it as it is(a directory with java files, each one containing the proper package statement).
    First I tried to setup my library using the Netbeans IDE 5.0.
    (Right click the libraries node in the project iew->properties>-Libraries->Add Jar/Folder) Source code still cant find any of the classes contained in the jar file.
    The netbeans interface can be a bit involved, so I switched to BlueJ just to see if my client class was able to find anything (Tools->preferences->Libraries->add).
    I've tried multiple variations trying to explain to the the source code where the liberary is located. Should the files in the library be compiled before it can be used as a jar? Have I set up my classpath correctly? I'm using windows XP, and I've placed the classpath by going to system properties-advanced tab->envirornment variables and typing it under the system variables.Is
    this wrong? Should it be someplace else? Haven't BlueJ or netbeans their own setup for classpaths? And why the need to type anything else in the classpath, when the dot in CLASSPATH=.;c:\Java;c:\suff;c:\andSoOn; actually means everything? Would it not be the same to just
    write CLASSPATH=.;?
    I seem to be getting off topic here, sorry about that. All I want is to be able to use my class library with my source code.
    PS: I've used the terms "source code" and "client class" arbitrarely. They are both the same.
    Message was edited by:
    javabra

    Have I set up my classpath
    correctly? I'm using windows XP, and I've placed the
    classpath by going to system properties-advanced
    tab->envirornment variables and typing it under the
    system variables.Is
    this wrong? That can work, but changing the CLASSPATH environment variable every time you want to run a program isn't recommended. Instead, you should you use the -classpath option of the javac command to compile your programs. Here is the syntax
    C:> javac -classpath C:\folder1;C:\folder2\subfolder1 MyClass.java
    Tip: construct your command in a text editor, so if it doesn't work, you can modify it and then copy and paste it into your DOS window. That will save you from having to retype the whole command in the DOS window.
    And
    why the need to type anything else in the classpath,
    when the dot in
    CLASSPATH=.;c:\Java;c:\suff;c:\andSoOn; actually
    means everything? Would it not be the same to just
    write CLASSPATH=.;? No. The dot means to look in the current directory. Suppose you have a DOS window open and you change directories to an existing directory on your computer called C:\folder1\subfolder1:
    something here>cd C:\folder1\subfolder1
    C:\folder1\subfolder1>Now, let's say you want to compile the MyClass.java file and it's in subfolder1. Also, suppose MyClass.java imports a class in folder1. If you use this command to compile:
    C:\folder1\subfolder1>
    javac -classpath . MyClass.java
    the current directory is C:\folder1\subfolder1 (note: I put the javac command on a different line for clarity). The -classpath is the dot, which instructs javac to look in the current directory for the classes referred to in the program MyClass.java. Since by assumption the class referred to by MyClass.java is not in subfolder1, the program won't compile. Also, the current directory does not include files in subdirectories of the current directory.
    Unfortunately, one of the biggest barriers to learning java is learning how to compile and execute programs. I still have trouble, and I constantly revise the rules I follow to take into account some new thing I stumbled on. Here are the current rules I follow:
    =================================
    EXAMPLE DIRECTORY STRUCTURE:
    D:\javaStuff\aFolder\TryPackage.java
    TryPackage.java is in the aFolder package and references the Line and Point classes. Line.java and Point.java are in the Geometry package, and they reside in the Geometry folder like this:
    C:\moreJava\Packages\Geometry\Line.java
    ====================================
    COMPILING: Use cd to change the DOS prompt to the current directory of the FILE you are trying to compile. In the -classpath option, include the classpaths to packages of all CLASSES referenced in your program whether they are in an import statement or not. If the file you want to compile is in the current directory, the compiler can find your FILE--it uses "." for the default location. To compile TryPackage.java above use this command:
    D:\javaStuff\aFolder>
    javac -classpath C:\moreJava\Packages filename
    where filename = TryPackage.java. If your FILE is not in the current directory, then you need to use the full path name of the FILE like this: filename = d:\javaStuff\aFolder\TryPackage.java
    RUNNING: In -classpath, include all paths to all packages of the classes USED in the program, which includes the path to the package of the .class file you are trying to run. If the .class file you are trying to run is not in a named package, then it is part of the default package, and the -classpath for that package must be included. For the default package, the -classpath equals the path to the directory that contains the file. If TryPackage.java did not have a package statement, the -classpath to the default package would be D:\javaStuff\aFolder. In addition, you need tack on the package name to the beginning of the .class file you compiled. Here is how you would run the TryPackage program:
    D:\javaStuff\aFolder>
    java -classpath C:\moreJava\Packages;D:\javaStuff filename
    where filename = aFolder.TryPackage. It does not matter if the .class file you are trying to run is in the current directory or not. The preceding command will work from any directory.
    ADDITIONAL RULES: You don't necessarily have to specify the full path name to the file when you are at a prompt other than the directory which contains the file. Instead, you can just complete the path to the file from the current directory, i.e. the prompt. For instance, if this is the directory structure:
    C:
    ----javaPrograms
    -----------Pack1
    -----------------DemoA.java
    and you are at the prompt:
    C:\javaPrograms>
    You can compile DemoA.java with this command:
    javac Pack1\DemoA.java
    Note that if you add the prompt directory to the path specified for the file, you get:
    C:\javaPrograms + Pack1\DemoA.java = C:\javaPrograms\Pack1\DemoA.java
    which results in the full path name to the file. So, javac can use the prompt directory as the starting point for path to the file you are compiling.
    The same thing works for the java command when you execute your program. Assume you are at the C:\ prompt:
    C:\>
    You can compile the program using:
    javac javaPrograms\Pack1\DemoA.java
    (Note: I've only completed the path to the file from the current directory). I can execute the program using:
    java -classpath javaPrograms Pack1.DemoA
    The java command completes the path to package. The prompt directory added to the -classpath is:
    C:\ + javaPrograms = C:\javaPrograms
    which is the full path to the parent directory of the package.

  • Package not found when nested

    When I tried to make packages in this way:
    ApplicationProgram (import TalepDurum.gui.Kurumlar.*;)
    TalepDurum(package)
    --gui(package)
    | --Kurumlar(package)
    |
    --TalepType(package)
    and I tried to reach the Kurumlar package from the
    ApplicationProgram, then it gives an error
    saying that no such a package or classpath not found.
    Anyone who understand the problem? Thanks for help...

    This might help.
    http://java.sun.com/docs/books/tutorial/java/interpack/packages.html
    If you have a directory structure of TalepDurum/gui/Kurumlar and the directory that contains TalepDurum is in your Classpath when you compile, then it will work.

  • Problem with java packages

    i have defined a package that contains numerous files. the package is com.assignment. now there are two files inside the package namely member and friends. when i try to call the member class in the friends class
    suppose member newmember; it gives me symbol not found error if i include "package com.assignment" at the top of both or one of the files but if i remove those then it compiles perfectly. i cant remove the package heading as i need it for other purpose. what is the way of getting around this problem so that i can include the package name and also link two classes within the package? can someone please help me out.

    Check ur classpath and also folder structure of the source
    This might help to understand package and classpath better
    http://www.jarticles.com/package/package_eng.html

  • Import package does not exist  java

    Hi ,
    i try to compile as following
    javac -cp "myapplication.jar:." modelapp.java
    my batch file as follwong
    set PATH=C:\Program Files\Java\jdk1.6.0_32\bin;C:\Users\DELL\Downloads\myfolder;C:\Users\DELL\Downloads\myfolder\edu;
    set CLASSPATH=C:\Program Files\Java\jdk1.6.0_32\bin;C:\Users\DELL\Downloads\myfolder;C:\Users\DELL\Downloads\myfolder\edu;
    cd C:\Users\DELL\Downloads\Stanfordnew
    but the error appear as following
    package edu.appli.machr. doesn't exist
    import package edu.appli.machr. doesn't exist
    i have already add the package to classpath
    please help me in how can i solve this problem.
    tHANKS

    javac -cp "myapplication.jar:." modelapp.java You compile on Linux and run on Windows or something? That is the Linux classpath, on Windows the list separator is ; If you do everything on Windows I'm a bit amazed it worked.
    set CLASSPATH=C:\Program Files\Java\jdk1.6.0_32\bin;C:\Users\DELL\Downloads\myfolder;C:\Users\DELL\Downloads\myfolder\edu;You made a copy/paste mistake, the classpath contains the path.
    please help me in how can i solve this problem.Research what the classpath actually is. Google can easily provide you plenty of articles describing it.

Maybe you are looking for

  • IOS 5 bug in double speed playback

    There is a newly introduced bug in iOS 5 with regard to playing podcasts at double speed (using the little 2x symbol in the top right). The playback works just fine and it is a great way to consume a lot of podcasts quickly, but if I make a phone cal

  • Applet size to 100% of frame

    We have a Swing JApplet containing a JTree in a JScrollPane that's part of an HTML frameset. The applet needs to fill 100% of its frame on loading and then resize with the frame. I figured then the best way to do this would be to set width and height

  • External or internal storage

    oh man, a coupla things. Just got the 2.66 MacPro. Have perused many of these topics concerning boot drives (the WD 150 Raptor not set up as a RAID is what I'm leaning towards) and yet I still have questions! As mentioned I'm setting up with 3 gigs o

  • The break 10.12

    Break Report We have a book Oracle Report 2.5 and show to create a break report. Now, we are using 10.12 and we would like to learn creating the break. We also wonder Pro and Con among the break with Tabular, Group left( Above), Matrix (With Group),

  • Report6i is getting hanged when i am using truncate command in srw.do_sql

    Hi All, I am using Reports 6.0.8.18.0 and oracle 9.2.0.1 on Windows XP with SP1. I am having a report in which i have used "truncate table <tablename>" command using SRW.do_sql command. some times report is getting hanged and some times it is giving