DrJava Version : drjava-20120818-r5686
DrJava Build Time: 20120818-0422
Java Version: Amazon Corretto 1.8.0_242
Topic: javax.swing
Error: The type javax.swing.JComponent cannot be resolved. It is indirectly referenced from required .class files
So far, I have been very successful in using Amazon Corretto with Dr. Java. However, I am working with a simple GUI application that will not compile in Dr. Java. It does compile and run in JGrasp, another Java IDE on the same system.
The JFrame command seems to work. Errors appear centered around the JPanel component.
Sample Code:
import javax.swing.*;
public class SimpleExample
{
static private JPanel panel; // To reference a panel
static private JLabel messageLabel; // To reference a label
public static void main(String [] args) {
JFrame window = new JFrame(); window.setTitle("Test"); window.setSize(310,400); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); messageLabel = new JLabel("Hello World"); panel = new JPanel();
** panel.add(messageLabel); //produces error JComponent cannot be resolved
window.add(panel); //produces erroradd is undefined for javax.swing.JPanel
window.setVisible(true);
}
}
My error. I recently updated my system. It seems I am having a broader issue of Dr. Java not finding classes/libraries on my Windows 10 Pro system. (It was working great with Coretto on Windows 7.) So, the issue isn't tied to the javax.swing class alone. (Funny that JFrame worked well tho!)
I will see if I can figure out why Dr. Java isn't hapy in its new environment on my machine.
Thanks.
Looking back at my Dr. Java version #, it seems I grabbed an ancient version. Dr. Java has it listed as "Old stable version" on the website. I just didn't catch how old. Downloaded the newer version and all seems fine.
Try the most recent build of DrJava (called drjava.jar at
www.cs.rice.edu/~javaplt/drjavarice/).. I am currently using it on my
Windows 10 laptop. The JDK I am using (as reported by running "java
-version" in the Command Prompt window) is:
openjdk version "1.8.0_242"
OpenJDK Runtime Environment Corretto-8.242.08.1 (build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM Corretto-8.242.08.1 (build 25.242-b08, mixed mode)
I found that installing multiple versions of Java on my Windows laptop
caused problems but I don't know enough about Windows 10 internals (and
registry magic) to know exactly why. I uninstalled all of my other
installations of Java on Windows 10 including a version of Amazon Corretto
8 on the WSL 1.0 Linux subsystem. (I recently installed the Ubuntu Linux
OpenJDK 8 version of Java within WSL 2.0 Linux subsystem which uses
virtualization so I suspect that it is invisible on the Windows side.. (WSL
1.0 uses the underlying NTFS file system of Windows 10 while WSL 2.0 uses a
virtual disk instead.)
-- Corky
On Fri, Mar 27, 2020 at 12:42 AM Jane Rossman jrossman@users.sourceforge.net wrote:
Related
Support Requests: #361