Java Error ???

mikeshn

Senior member
Oct 9, 2001
367
0
0
Hello

I write small program and try to compile and got error message.

bash-2.03$ javac Mediator_Interface.java
Mediator_Interface.java:1: Package javax.swing not found in import.
import javax.swing.* ;
^
Mediator_Interface.java:5: Superclass JFrame of class Mediator_Interface not found.
public class Mediator_Interface extends JFrame {
^

Jus don?t understand what I did wrong. The code is given below:

import javax.swing.* ;

public class Mediator_Interface extends JFrame {

public static void main(String args[]) {
new Mediator_Interface();
}

public Mediator_Interface() {
super("Mediation Advisors"); // Frame with title
setDefaultCloseOperation( DISPOSE_ON_CLOSE );
JTabbedPane jtp = new JTabbedPane(JTabbedPane.LEFT);
getContentPane().add( jtp );
jtp.add( new JButton("Show Cases"), "Cases");
jtp.add( new JLabel("Show Cases"), "Cases");
jtp.add( new JLabel("Log Out"), "Log Out");
System.out.println("");

setSize( 800, 600 ); // initial width, height
setLocation( 150,100 );
setVisible( true ); // shows the window
}
}



 

manly

Lifer
Jan 25, 2000
12,504
3,339
136
Type the command java -version at the command line.

You need Java2 1.2.0 or later to have Swing built-in.

Swing can be added on top of Java 1.1 but in that case, I'd recommend upgrading to 1.4 instead.
 

mikeshn

Senior member
Oct 9, 2001
367
0
0
That' what I get

bash-2.03$ java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
bash-2.03$


 

JetBlack69

Diamond Member
Sep 16, 2001
4,580
1
0
It compiles and runs fine here. (windows XP) let me try my linux machine.

Edit: runs fine on my linux machine and I have java 1.4
 

manly

Lifer
Jan 25, 2000
12,504
3,339
136
That's odd. Assuming the environment variable JAVA_HOME is set, try this command:

$ unzip -l $JAVA_HOME/jre/lib/rt.jar | grep swing

That should show all the Swing classes in your Java2 runtime class library. To be honest, I'm baffled.