|
|
Re: Exception in thread "main" java.lang.Error: Unresolved compilation problem [message #983023 is a reply to message #982662] |
Tue, 13 November 2012 16:03 |
|
On 11/13/2012 8:09 AM, Heits Mkivi wrote:
> Hello! I have a problem with this. I dont know how to resolve the
> problem. I just wanted to learn how to make a simple game.
> I've searched google for a fix but i didnt understand it.
> Im trying to make a game with a tutorial
>
>
> Exception in thread "main" java.lang.Error: Unresolved compilation problem:
> at aa.main(aa.java:8)
>
> import javax.swing.*;
>
> public class aa {
> public static ab f;
> public static width = 800
> public static height = 600
> public static void main(String[] args) {
> f = new ab();
> f.setVisible(true);
> f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
> f.setResizable(false);
> f.setSize(800, 600);
> f.setTitle("My Game");
> }
> }
First, this isn't a forum for helping beginning Java coders learn to fix
syntax and other errors. There are proper forums for that
(javaranch.com, jguru.com, et al., even stackoverflow.com).
Second, you're not following good practice in your Java code, so you're
not using a decent book or tutorial. (I'll let you discover what prompts
this remark.)
Third, you give the error--and line number, but no line numbers in your
example code. As a package statement is the first line in a Java file
(though there could be infinite blank lines before it), and it's missing
here, it's not possible to intuit with much accuracy what's going on on
line 8 because we don't know which is line 8.
This said, Java statements are separated by semi-colons. You're missing
them from two of three static variable definitions. I'm not a Swing guy,
but I'd start there.
A great book to read if you're serious about learning Java is Head First
Java from O'Reilly. Great Java reference works to have on your shelf are
Thinking in Java by Bruce Eckel and Effective Java by Joshua Bloch.
(Note: I am not rewarded for these recommendations.)
|
|
|
Powered by
FUDForum. Page generated in 0.07303 seconds