Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Swing / AWT compile errors

  1. #1
    Junior Member
    Join Date
    Feb 2021
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Swing / AWT compile errors

    Hi!

    I just installed the latest eclipse and latest java (SE11). I am revisiting some old code and get a lot of compile errors. All in swing and awt package.

    Some sample lines that give compile errors:

    import java.awt.BorderLayout;
    import javax.swing.Action;


    I get this compile errors

    Description Resource Path Location Type
    The package java.awt is not accessible TestGUI.java Java Problem

    Description Resource Path Location Type
    The type javax.swing.Action is not accessible Java Problem



    This comes from a project i just created. I copy pasted some code (gui related) from an old program. The old program still compiles fine, but the new
    program(with the same code) gives me these error.

    How do i fix this?

    Thanks

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Swing / AWT compile errors

    Can you paste here a small, complete program that gives the errors you are talking about?
    Copy the full contents of the error messages and paste it here also.

    From Google: https://stackoverflow.com/questions/...olved/51504409
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    javamonkey123 (February 16th, 2021)

  4. #3
    Junior Member
    Join Date
    Feb 2021
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Swing / AWT compile errors

    Indeed the solution was to add this line:

    requires java.desktop;


    To the module-info.java file.

Similar Threads

  1. Class method followWallsRight- formatting and compile errors
    By rmcoder in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 6th, 2018, 08:39 PM
  2. Compile Errors
    By acl2011 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 12th, 2012, 12:19 PM
  3. Couple compile errors for dice game
    By smithmar in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 8th, 2012, 01:16 PM
  4. Remaining compile errors: no suitable method found for & cannot find symbol
    By ChuckLep in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 12th, 2011, 03:33 PM
  5. Replies: 2
    Last Post: January 7th, 2011, 09:10 PM