Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Problem on Linux

 
Reuben Cleetus
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I'm a Linux newbie, and only recently figured out how to install Java using an RPM package!
I have a wierd problem using Java -- when I try to import any swing packages (ex: javax.swing.*), the javac compiler complains and seems unable to find the swing libraries. However, I am able to import any awt libraries.
Is there anything special I have to do to get swing working in Linux? I thought swing was now part of the Java's standard library, so that no additional classpath needed to be set to use swing.
Any help would be greatly appreciated!
Regards,
Reuben Cleetus.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're correct. From 1.3 onward, Swing is part of the bundle (actually, 1.2, but it's buggy in that release).
The easiest way to install Java in a RedHat-like (rpm-based) Linux is to download the JDK, run the download to unpack the rpm, do a "rpm -ivh" to install it and then set your JAVA_HOME environment variable to point to the installed JDK. Actually, I 'm not sure if JAVA_HOME is required, but many apps like to have one. For my latest JDK, it's
"JAVA_HOME=/usr/java/jdk1.1.3" or something like that.
Make sure your CLASSPATH isn't set to use any older Java installations, though!
 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you type
java -version
from the command-line, what do you get?
 
Reuben Cleetus
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,
When I type java -version, it tells me that my Java version is "1.4.0-beta3".
This is a fresh install of Linux (SuSE), and JDK 1.4 is the first and only JDK that I have installed on it. I'm unable to figure out just why any class with a swing import in it fails to compile.
Regards,
Reuben.
 
Greg Brouelette
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Type
which javac
and then
which java
and see if you're using the java compiler that was installed in the 1.4 installation. There are 2 bits of info that lead me to this:
1. I know that my Mandrake installation installs Kaffe directly into the /usr/bin directory. Kaffe uses a 1.1 implementation of java so the swing classes arn't there. Since /usr/bin is in your path first it picks up the javac program from there instead of from the 1.4 installation.
2. I know the 1.4 installation works on my Mandrake installation and a buddy of mine has it working on his Suse installation.
So this may be it. Hope it helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic