| Author |
Java not installed right?
|
Josh Bowman
Greenhorn
Joined: Jan 01, 2005
Posts: 4
|
|
I recently installed java on my windows system, (I'm home from school for a few weeks) and I am having trouble compiling any programs that use AWT stuff. Here is my program: ----begin code---- ----end code---- When I attempt to compile it, I get the following errors: ---begin errors---- Animate.java:19: incompatible types found : java.awt.Graphics required: Graphics g=f.getGraphics(); ^ Animate.java:21: cannot find symbol symbol : method setColor(java.awt.Color) location: class Graphics g.setColor(Color.white); ^ Animate.java:22: cannot find symbol symbol : method fillRect(int,int,int,int) location: class Graphics g.fillRect(0,0,500,500); ^ Animate.java:28: cannot find symbol symbol : method setColor(java.awt.Color) location: class Graphics g.setColor(Color.white); ^ Animate.java:29: cannot find symbol symbol : method fillOval(int,int,int,int) location: class Graphics g.fillOval(x-1,400,40,40); ^ Animate.java:30: cannot find symbol symbol : method setColor(java.awt.Color) location: class Graphics g.setColor(Color.green); ^ Animate.java:31: cannot find symbol symbol : method fillOval(int,int,int,int) location: class Graphics g.fillOval(x,400,40,40); ^ .\Graphics.java:5: cannot find symbol symbol : class frame location: class Graphics frame f = newFrame("Example 1"); ^ .\Graphics.java:5: cannot find symbol symbol : method newFrame(java.lang.String) location: class Graphics frame f = newFrame("Example 1"); ^ .\Graphics.java:6: cannot find symbol symbol : class graphics location: class Graphics graphics g; ^ 10 errors ---end errors---- could someone please enlighten me to what I'm doing wrong? thanks in advance, josh (Marilyn added code tags) [ January 02, 2005: Message edited by: Marilyn de Queiroz ]
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
frame f = newFrame("Example 1");
Try: Frame f = new Frame("Example 1");
|
Mike Gershman
SCJP 1.4, SCWCD in process
|
 |
Jerry Kilpatrick
Greenhorn
Joined: Jan 02, 2005
Posts: 6
|
|
OK, I am confused. I took this code "as is" and it compiled and ran on my system.
|
 |
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
|
|
It also ran on my system. My guess is that Microsoft's java is superceding Sun's java. Try editing your PATH environment variable and put %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin; at the front of your PATH. I may be somewhere towards the end, and it may look slightly different -- %JAVA_HOME% is where your j2sdk lives. e.g. C:\j2sdk1.4.2_06
|
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
|
 |
Josh Bowman
Greenhorn
Joined: Jan 01, 2005
Posts: 4
|
|
Okay, I fixed this, but it doesn't really make sense. I edited my PATH, and I also changed the top of the program from: import java.awt.*; --to---> import java.awt.Graphics; import java.awt.Color; import java.awt.Frame; and it now compiles and runs correctly. The only problem is, I don't know why it was being stupid in the first place
|
 |
Mike Gershman
Ranch Hand
Joined: Mar 13, 2004
Posts: 1272
|
|
And I'm very curious about the error message you posted quoting the statement: frame f = newFrame("Example 1"); which doesn't appear in the source code you posted.
|
 |
Josh Bowman
Greenhorn
Joined: Jan 01, 2005
Posts: 4
|
|
|
Yeah, I don't understand that either.
|
 |
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
|
|
|
I guess you could change the code back to using java.awt.* to see if it makes a difference ...
|
 |
Josh Bowman
Greenhorn
Joined: Jan 01, 2005
Posts: 4
|
|
|
I tried compiling with "java.awt.*;". It gave the same errors as the initial ones.
|
 |
 |
|
|
subject: Java not installed right?
|
|
|