Sublime Forum

I cant compile and run a Java GUI program in ST 3

#1

Hi,

I’m a beginner java programmer and I’ve tried to run a program that imports following packages:

import java.io.*; import java.awt.*; import java.awt.event.*; import java.swing.*; import java.swing.border.*;

But when I hit CTRL + B, I got errors like this and so on:

AddressBook.java:4: error: package java.swing does not exist import java.swing.*; ^ AddressBook.java:5: error: package java.swing.border does not exist import java.swing.border.*; ^ AddressBook.java:7: error: cannot find symbol public class AddressBook extends JFrame { ^ symbol: class JFrame AddressBook.java:21: error: cannot find symbol private JTextField jtfName = new JTextField(NAME_SIZE); ^ symbol: class JTextField location: class AddressBook

What’s the matter? How can I import those packages?

0 Likes

#2

I think you just need to change it to import javax.swing.*; and import javax.swing.border.*;

2 Likes

#3

Still gives the same errors. Besides, what you said is just ignoring the unrelated packages. That has nothing to do with the problem packages.

0 Likes

#4

You have changed java to javax in both import statements?

1 Like

#5

Ah, I’m terribly sorry. I missed the javax difference. I did not pay much attention.

and, it certainly works now. Thanks :slight_smile:

1 Like