Can't locate Javax  
Author Message
Asad Khan





PostPosted: 2003-10-16 22:22:00 Top

java-programmer, Can't locate Javax Hi,

I am using DrJava, and I am writing a program that has the following
statement:

import javax.swing;

It gives me this error when compiled:

File: C:\Program Files\DrJava\CustomJFrame.java [line: 1]
Error: package javax does not exist

I did set my classpath variable to:

c:\j2sdk1.4.2\lib\tools.jar;C:\j2sdk1.4.2_01\src\javax

where C:\j2sdk1.4.2_01\src\javax is where javax is located.

What am I doing wrong?



 
ak





PostPosted: 2003-10-16 22:32:00 Top

java-programmer >> Can't locate Javax forget tools.jar and src - you need c:\j2sdk1.4.2\lib\rt.jar


"Asad Khan" <email***@***.com> schrieb im Newsbeitrag
news:6Qxjb.135309$ko%email***@***.com...
> Hi,
>
> I am using DrJava, and I am writing a program that has the following
> statement:
>
> import javax.swing;
>
> It gives me this error when compiled:
>
> File: C:\Program Files\DrJava\CustomJFrame.java [line: 1]
> Error: package javax does not exist
>
> I did set my classpath variable to:
>
> c:\j2sdk1.4.2\lib\tools.jar;C:\j2sdk1.4.2_01\src\javax
>
> where C:\j2sdk1.4.2_01\src\javax is where javax is located.
>
> What am I doing wrong?
>
>
>


 
Michael Borgwardt





PostPosted: 2003-10-16 23:00:00 Top

java-programmer >> Can't locate Javax Asad Khan wrote:
> Hi,
>
> I am using DrJava, and I am writing a program that has the following
> statement:
>
> import javax.swing;
>
> It gives me this error when compiled:
>
> File: C:\Program Files\DrJava\CustomJFrame.java [line: 1]
> Error: package javax does not exist
>
> I did set my classpath variable to:
>
> c:\j2sdk1.4.2\lib\tools.jar;C:\j2sdk1.4.2_01\src\javax
>
> where C:\j2sdk1.4.2_01\src\javax is where javax is located.
>
> What am I doing wrong?

Several things:

- You're trying to import a package. That is impossible. You probably mean
import javax.swing.*;

- You're trying to put the SDK *source* directory in the classpath. That is wrong twice
over, because the JDK will find its core classes without them being in the classpath,
and even if they had to be in the classpath, you'd had to add the compiled classes
(which are in rt.jar) and not the sources.

So simply don't set a classpath variable at all, and correct the import statement.

 
 
David Zimmerman





PostPosted: 2003-10-16 23:02:00 Top

java-programmer >> Can't locate Javax You don't need to ever specify rt.jar on your classpath, its part of the
default bootclasspath.

You need to change your import slightly

import javax.swing.*;

ak wrote:

> forget tools.jar and src - you need c:\j2sdk1.4.2\lib\rt.jar
>
>
> "Asad Khan" <email***@***.com> schrieb im Newsbeitrag
> news:6Qxjb.135309$ko%email***@***.com...
>
>>Hi,
>>
>>I am using DrJava, and I am writing a program that has the following
>>statement:
>>
>> import javax.swing;
>>
>>It gives me this error when compiled:
>>
>> File: C:\Program Files\DrJava\CustomJFrame.java [line: 1]
>> Error: package javax does not exist
>>
>>I did set my classpath variable to:
>>
>> c:\j2sdk1.4.2\lib\tools.jar;C:\j2sdk1.4.2_01\src\javax
>>
>>where C:\j2sdk1.4.2_01\src\javax is where javax is located.
>>
>>What am I doing wrong?
>>
>>
>>
>
>
>