CLASSPATH problems


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: CLASSPATH problems

  1. #1
    Join Date
    Jun 2004
    Posts
    9

    Question CLASSPATH problems

    Greetings every1,
    I'm new to Java, currently i'm working on packages & interfaces. I'm working in D:\Was\Java\MyPrograms.
    I made a folder and named it MyPack, then placed this code in it.
    Code:
    package MyPack;
    class A {
    A() {
    system.out.println("Inside A");
    }
    }
    class Test {
    public static void main(String args[]){
    A obj1=new A();
    }
    }
    I'm saving this file with the name MyPack.java in the MyPack folder. Then I compiled it, and everything is fine. But when i execute it, it shows some errors. I know this is coz the path is not correct in CLASSPATH. I set it like this set CLASSPATH=.;D:\Was\Java\MyPrograms; but still no use. Can any1 plz help me.

    [ArchAngel added CODE tags]

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    It helps if you post error messages.

    I'm guessing that it's in the way you are trying to run your program.

    1. Change into the folder above "MyPack":

    c:\>cd projects
    c:\projects>

    In this case, the folder "MyPack" is within c:\projects.

    2. Execute your file:

    c:\projects> java MyPack.A
    ArchAngel.
    O:-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center