Results 1 to 3 of 3

Thread: Java compiler error - Linux

  1. #1
    Junior Member
    Join Date
    Apr 2003
    Posts
    12

    Java compiler error - Linux

    Hello. I'm having a problem trying to compile Java apps in Linux. Code is below:

    import javax.swing.*;

    public class test {
    public static void main( String[] args ) {
    JFrame frame = new JFrame( "Hello, Java" );
    JLabel label = new JLabel( "this is a JLabel", JLabel.CENTER );
    frame.getContentPane().add( label );
    frame.setSize( 300, 300 );
    frame.setVisible( true );
    }
    }

    I'm getting "test.java:5: error:Cannot find class "JFrame" [JLS 8]

    I have j2sdk1.4.0 installed, which is supposed to include swing. I'm a bit stumped & was wondering if anyone here could give me some direction.

    Many, many thanks in advance.

    ea

  2. #2
    Senior Member
    Join Date
    Jun 2002
    Posts
    405
    I just tested your program out on my computer and it compiled fine, I'm on Windows 2000 using version 1.4.1 though. When I installed it I had to fix up my PATH environment variable to ensure that it could find all the Java programs (java, javac etc.), you might also have to fix up your path settings.

    [edit]
    Found page which goes through setting up Java on a Linux platform, maybe worth double-checking to ensure that everything is in working order.

    % su -
    # cd /usr/local/
    # chmod +x j2sdk-1_4_1_02-linux-i586.bin
    # ./j2sdk-1_4_1_02-linux-i586.bin

    Now test Java:

    # /usr/local/j2sdk1.4.1_02/bin/java -version

    Set the PATH environent variable: (/etc/profile or .bashrc).

    PATH="$PATH:/usr/local/j2sdk1.4.1_02/bin:."
    export PATH
    http://www.dougsparling.com/comp/howto/linux_java.html
    [/edit]

  3. #3
    Junior Member
    Join Date
    Apr 2003
    Posts
    12
    You are very cool. Thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •