This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java not installed right?

 
Josh Bowman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
frame f = newFrame("Example 1");


Try:
Frame f = new Frame("Example 1");
 
Jerry Kilpatrick
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I am confused. I took this code "as is" and it compiled and ran on my
system.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
Josh Bowman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I don't understand that either.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you could change the code back to using java.awt.* to see if it makes a difference ...
 
Josh Bowman
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried compiling with "java.awt.*;". It gave the same errors as the initial ones.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic