For Programmers: Free Programming Magazines  


Home > Archive > Java Help > September 2004 > cannot resolve symbol









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cannot resolve symbol
Michael

2004-09-25, 8:57 pm

I am having a problem compiling my program that I think is related to
my classpath. All of my swing components create unresolved symbols in
their declarations. Here are my compile errors:

C:\Documents and Settings\Michael\My
Documents\School\CSC3360\Concentration>java
c Concentration.java
Concentration.java:18: cannot resolve symbol
symbol : class Jframe
location: class Concentration
Jframe f = new ConcentrationFrame("Concentration");
^
..\ConcentrationFrame.java:16: cannot resolve symbol
symbol : class Jframe
location: class ConcentrationFrame
public class ConcentrationFrame extends Jframe {
^
..\ConcentrationFrame.java:18: cannot resolve symbol
symbol : class Jpanel
location: class ConcentrationFrame
private Jpanel centerPanel =
^
..\ConcentrationFrame.java:20: cannot resolve symbol
symbol : class Jpanel
location: class ConcentrationFrame
private Jpanel buttonPanel =
^
..\ConcentrationFrame.java:22: cannot resolve symbol
symbol : class Jlabel
location: class ConcentrationFrame
private Jlabel statusLabel =
^
..\ConcentrationFrame.java:19: cannot resolve symbol
symbol : class Jpanel
location: class ConcentrationFrame
new Jpanel(new FlowLayout(FlowLayout.CENTER, 20, 20));
^
..\ConcentrationFrame.java:21: cannot resolve symbol
symbol : class Jpanel
location: class ConcentrationFrame
new Jpanel(new GridLayout(4, 6, 20, 20));
^
..\ConcentrationFrame.java:36: cannot resolve symbol
symbol : method setBackground (java.awt.Color)
location: class ConcentrationFrame
setBackground(new Color(255, 255, 255));
^
..\ConcentrationFrame.java:58: cannot resolve symbol
symbol : variable f
location: class ConcentrationFrame
Container contentPane = f.getContentPane();
^
..\ConcentrationFrame.java:65: cannot resolve symbol
symbol : variable EXIT_ON_CLOSE
location: class ConcentrationFrame
setDefaultCloseOperation(EXIT_ON_CLOSE);

^
10 errors

As you can see, I am not certain that the compiler is seeing the
javax.swing file in the classpath. I had this problem before in a
program using only awt and changed both my path and classpath to the
following:

PATH = C:\j2sdk1.4.2_05\bin;C:\Program Files\SSH Communications
Security\SSH Secure Shell
CLASSPATH = .;C:\Program Files\Java\j2re1.4.1\lib\ext\QTJava.zip

Everything before the semicolon was added to both environment
variables by me to resolve the compilation issues I had with the
previous program. However, that program compiles fine now. Please
help!

Here is the driver class. The helper class imports the same packages.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

// Driver class
public class Concentration {
public static void main(String[] args) {
Jframe f = new ConcentrationFrame("Concentration");
Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = f.getSize();
f.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
f.pack();
f.setVisible(true);
}
}

Hope this helps.
George W. Cherry

2004-09-26, 3:56 am


"Michael" <michaelyaeger@hotmail.com> wrote in message
news:5ee31395.0409251632.1bc337d8@posting.google.com...
> I am having a problem compiling my program that I think is related to
> my classpath. All of my swing components create unresolved symbols in
> their declarations. Here are my compile errors:
>
> C:\Documents and Settings\Michael\My
> Documents\School\CSC3360\Concentration>java
> c Concentration.java
> Concentration.java:18: cannot resolve symbol
> symbol : class Jframe
> location: class Concentration
> Jframe f = new ConcentrationFrame("Concentration");
> ^
> .\ConcentrationFrame.java:16: cannot resolve symbol
> symbol : class Jframe
> location: class ConcentrationFrame
> public class ConcentrationFrame extends Jframe {
> ^
> .\ConcentrationFrame.java:18: cannot resolve symbol
> symbol : class Jpanel
> location: class ConcentrationFrame
> private Jpanel centerPanel =
> ^
> .\ConcentrationFrame.java:20: cannot resolve symbol
> symbol : class Jpanel
> location: class ConcentrationFrame
> private Jpanel buttonPanel =
> ^
> .\ConcentrationFrame.java:22: cannot resolve symbol
> symbol : class Jlabel
> location: class ConcentrationFrame
> private Jlabel statusLabel =
> ^
> .\ConcentrationFrame.java:19: cannot resolve symbol
> symbol : class Jpanel
> location: class ConcentrationFrame
> new Jpanel(new FlowLayout(FlowLayout.CENTER, 20, 20));
> ^
> .\ConcentrationFrame.java:21: cannot resolve symbol
> symbol : class Jpanel
> location: class ConcentrationFrame
> new Jpanel(new GridLayout(4, 6, 20, 20));
> ^
> .\ConcentrationFrame.java:36: cannot resolve symbol
> symbol : method setBackground (java.awt.Color)
> location: class ConcentrationFrame
> setBackground(new Color(255, 255, 255));
> ^
> .\ConcentrationFrame.java:58: cannot resolve symbol
> symbol : variable f
> location: class ConcentrationFrame
> Container contentPane = f.getContentPane();
> ^
> .\ConcentrationFrame.java:65: cannot resolve symbol
> symbol : variable EXIT_ON_CLOSE
> location: class ConcentrationFrame
> setDefaultCloseOperation(EXIT_ON_CLOSE);

> ^
> 10 errors
>
> As you can see, I am not certain that the compiler is seeing the
> javax.swing file in the classpath. I had this problem before in a
> program using only awt and changed both my path and classpath to the
> following:
>
> PATH = C:\j2sdk1.4.2_05\bin;C:\Program Files\SSH Communications
> Security\SSH Secure Shell
> CLASSPATH = .;C:\Program Files\Java\j2re1.4.1\lib\ext\QTJava.zip
>
> Everything before the semicolon was added to both environment
> variables by me to resolve the compilation issues I had with the
> previous program. However, that program compiles fine now. Please
> help!
>
> Here is the driver class. The helper class imports the same packages.
>
> import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> import java.util.*;
>
> // Driver class
> public class Concentration {
> public static void main(String[] args) {
> Jframe f = new ConcentrationFrame("Concentration");
> Dimension screenSize =
> Toolkit.getDefaultToolkit().getScreenSize();
> Dimension frameSize = f.getSize();
> f.setLocation((screenSize.width - frameSize.width) / 2,
> (screenSize.height - frameSize.height) / 2);
> f.pack();
> f.setVisible(true);
> }
> }
>
> Hope this helps.


Java is case sensitive, and the names of the classes
you want are JFrame, JPanel, JLabel, and so on. You
may have other errors, but fix these first, and recompile.


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com