Can't locate Javax

A

Asad Khan

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?
 
M

Michael Borgwardt

Asad said:
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.
 
D

David Zimmerman

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.*;
forget tools.jar and src - you need c:\j2sdk1.4.2\lib\rt.jar


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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top