Results 1 to 4 of 4

Thread: packageProblem

  1. #1
    batia is offline Member
    Join Date
    Feb 2011
    Location
    Lithuania
    Posts
    16
    Rep Power
    0

    Default packageProblem

    Hello,

    What do i do wrong?
    With eclipse everything goes ok.

    Please look at attached screenshot.

    Maybe it's not very visible from attached file. The commands and output:


    C:\incomplete\JavaPackages\GOOSE>more test1.java
    package GOOSE;
    public class test1 {
    public static void main(String[] args){
    System.out.println("test output");
    }
    }

    C:\incomplete\JavaPackages\GOOSE>set CLASSPATH=C:\;%cd%;

    C:\incomplete\JavaPackages\GOOSE>set CLASSPATH
    CLASSPATH=C:\;C:\incomplete\JavaPackages\GOOSE;

    C:\incomplete\JavaPackages\GOOSE>javac test1.java

    C:\incomplete\JavaPackages\GOOSE>java GOOSE.test1
    Exception in thread "main" java.lang.NoClassDefFoundError: GOOSE/test1
    Caused by: java.lang.ClassNotFoundException: GOOSE.test1
    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)
    Could not find the main class: GOOSE.test1. Program will exit.

    C:\incomplete\JavaPackages\GOOSE>
    Attached Thumbnails Attached Thumbnails packageProblem-packageproblem.jpg  
    Last edited by batia; 03-14-2011 at 10:04 PM.

  2. #2
    cultclassic is offline Member
    Join Date
    Mar 2011
    Posts
    64
    Rep Power
    0

    Default

    run it from the folder one level up

    java GOOSE.test1

    from
    C:\incomplete\JavaPackages

  3. #3
    aadem is offline Member
    Join Date
    Mar 2011
    Posts
    22
    Rep Power
    0

    Default You

    You must run it from its parent folder (the folder that the GOOSE folder is in) as the previous poster said. Doublecheck your classpath as well i know in Unix when i specify my classpath i have to add :. to the end of it (. being current directory since current directory is no longer considered the classpath since you override the default by specifying it in the first place)

  4. #4
    batia is offline Member
    Join Date
    Feb 2011
    Location
    Lithuania
    Posts
    16
    Rep Power
    0

    Default

    Thank you, cultclassic, aadem,

    That solved the problem.

    In fact i can run it from where i want except package folder.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •