Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Exception in thread "main" java.lang.Error: Unresolved compilation problem
Exception in thread "main" java.lang.Error: Unresolved compilation problem [message #982662] Tue, 13 November 2012 10:07 Go to next message
Heits Mkivi is currently offline Heits MkiviFriend
Messages: 1
Registered: November 2012
Junior Member
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");
}
}
Re: Exception in thread "main" java.lang.Error: Unresolved compilation problem [message #982977 is a reply to message #982662] Tue, 13 November 2012 15:25 Go to previous messageGo to next message
Olivier Thomann is currently offline Olivier ThomannFriend
Messages: 518
Registered: July 2009
Senior Member
That code doesn't compile. You should have compile errors in your editor that you should fix before you try to run it.

import javax.swing.*;

public class aa {
public static ab f;
public static int width = 800;
public static int 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(width, height);
f.setTitle("My Game");
}
}

This would be better if you have a type named 'ab' in the same package (default package).
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 Go to previous message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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.)
Previous Topic:Reloading CTabItems in a CTabFolder
Next Topic:How to add text hovers for generic eclipse editor- generic text hover for all text editors
Goto Forum:
  


Current Time: Thu Apr 25 00:36:34 GMT 2024

Powered by FUDForum. Page generated in 0.07303 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top