The Artima Developer Community
Sponsored Link

Java Answers Forum
Class path problem

2 replies on 1 page. Most recent reply: May 6, 2004 9:02 AM by Shashank D. Jha

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Mubeen Shaik

Posts: 1
Nickname: mubeen
Registered: May, 2004

Class path problem Posted: May 4, 2004 10:58 AM
Reply to this message Reply
Advertisement
Hi all,
I am reading Thinking in JAVA and i am trying to compile the following code.It is giving me error on import statement.


code:
----------------------------------------------------------- ---------------------

//: C03: Assignment .java// Assignmnet with objects is bit tricky


import com.bruceeckel.simpletest.*;

class Number

{

int i;

}


public class Assignment {


static Test monitor = new Test();

public static void main(String [] args) {

Number n1 = new Number();

Number n2 = new Number();


n1.i = 9; n2.i = 47;


System.out.println("1 : n1.i : " +n1.i + " , n2.i: " +n2.i);


}

} ///:~

----------------------------------------------------------------------------- ---


==================

Compilation Error


code:
----------------------------------------------------------------- ---------------

C:\JAVA\Think\C03>javac Assignment.javaAssignment.java:5: package com.bruceeckel.simpletest

does not existimport com.bruceeckel.simpletest.*;^


Assignment.java:17: cannot access Testbad class file: C:\com\bruceeckel\simpletest\Test.classclass

file contains wrong class: com.bruceeckel.simpletest.TestPlease remove or

make sure it appears in the correct subdirectory of the classpath. static Test monitor = new Test();


^2 errors

----------------------------------------------------------------------- ---------

My Classpath is as follows




code:
------------------------------------------------------------- -------------------

C:\JAVA Software\lib;C:\JAVA Software\lib\tools.jar;

C:\JAVA Software\lib\dt.jar;C:\JAVA Software\jre\lib\rt.jar;.;

C:\com\bruceeckel\simpletest

------------------------------------------------- -------------------------------

===========

Please help me in compiling and understanding this program. I am sure that, i am missing something in classpath.

Thanks in advance,
Mubeen Shaik.






Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Class path problem Posted: May 5, 2004 9:32 AM
Reply to this message Reply
You must use C:\ as Classpath.

com.bruceeckel.simpletest.ClassName

searches for the file

%classpath%\com\bruceeckel\simpletest\ClassName.class

in your case:

c:\com\bruceeckel\simpletest\com\bruceeckel\simpletest\ClassName.class

Shashank D. Jha

Posts: 68
Nickname: shashankd
Registered: May, 2004

Re: Class path problem Posted: May 6, 2004 9:02 AM
Reply to this message Reply
Check first if the package name u are using is same as com.bruceeckel.simpletest

Flat View: This topic has 2 replies on 1 page
Topic: Setting java.library.path during runtime Previous Topic   Next Topic Topic: Switichin On\Off keyboard's LED display

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use