1
Im making a 2d Java Game using Eclipse. I have no real previous coding experience. I am trying to run it in the debug mode. this is the error when I try to run it.
This is the code:
Could someone tell me whats wrong, and how I can resolve these problems?
This is the code:
Could someone tell me whats wrong, and how I can resolve these problems?
Create an account or sign in to comment.
34
1
Oh you have no source code linked to the main code.
1
You forgot to put your class in a package!
1
It is in a package....
Also OP starting out if you dont want to get confused with IDEs I would suggest you simply start out with the old fashioned notepad + compiler setup.
Also OP starting out if you dont want to get confused with IDEs I would suggest you simply start out with the old fashioned notepad + compiler setup.
1
I actually started with eclipse. xD
1
On topic..
1
. . . . . . . . . . . . . . . . . . . ________
. . . . . .. . . . . . . . . . . ,.-‘”. . . . . . . . . .``~.,
. . . . . . . .. . . . . .,.-”. . . . . . . . . . . . . . . . . .“-.,
. . . . .. . . . . . ..,/. . . . . . . . . . . . . . . . . . . . . . . ”:,
. . . . . . . .. .,?. . . . . . . . . . . . . . . . . . . . . . . . . . .\,
. . . . . . . . . /. . . . . . . . . . . . . . . . . . . . . . . . . . . . ,}
. . . . . . . . ./. . . . . . . . . . . . . . . . . . . . . . . . . . ,:`^`.}
. . . . . . . ./. . . . . . . . . . . . . . . . . . . . . . . . . ,:”. . . ./
. . . . . . .?. . . __. . . . . . . . . . . . . . . . . . . . :`. . . ./
. . . . . . . /__.(. . .“~-,_. . . . . . . . . . . . . . ,:`. . . .. ./
. . . . . . /(_. . ”~,_. . . ..“~,_. . . . . . . . . .,:`. . . . _/
. . . .. .{.._$;_. . .”=,_. . . .“-,_. . . ,.-~-,}, .~”; /. .. .}
. . .. . .((. . .*~_. . . .”=-._. . .“;,,./`. . /” . . . ./. .. ../
. . . .. . .\`~,. . ..“~.,. . . . . . . . . ..`. . .}. . . . . . ../
. . . . . .(. ..`=-,,. . . .`. . . . . . . . . . . ..(. . . ;_,,-”
. . . . . ../.`~,. . ..`-.. . . . . . . . . . . . . . ..\. . /\
. . . . . . \`~.*-,. . . . . . . . . . . . . . . . . ..|,./.....\,__
,,_. . . . . }.>-._\. . . . . . . . . . . . . . . . . .|. . . . . . ..`=~-,
. .. `=~-,_\_. . . `\,. . . . . . . . . . . . . . . . .\
. . . . . . . . . .`=~-,,.\,. . . . . . . . . . . . . . . .\
. . . . . . . . . . . . . . . . `:,, . . . . . . . . . . . . . `\. . . . . . ..__
. . . . . . . . . . . . . . . . . . .`=-,. . . . . . . . . .,%`>--==``
. . . . . . . . . . . . . . . . . . . . _\. . . . . ._,-%. . . ..`\
Trial and error.
. . . . . .. . . . . . . . . . . ,.-‘”. . . . . . . . . .``~.,
. . . . . . . .. . . . . .,.-”. . . . . . . . . . . . . . . . . .“-.,
. . . . .. . . . . . ..,/. . . . . . . . . . . . . . . . . . . . . . . ”:,
. . . . . . . .. .,?. . . . . . . . . . . . . . . . . . . . . . . . . . .\,
. . . . . . . . . /. . . . . . . . . . . . . . . . . . . . . . . . . . . . ,}
. . . . . . . . ./. . . . . . . . . . . . . . . . . . . . . . . . . . ,:`^`.}
. . . . . . . ./. . . . . . . . . . . . . . . . . . . . . . . . . ,:”. . . ./
. . . . . . .?. . . __. . . . . . . . . . . . . . . . . . . . :`. . . ./
. . . . . . . /__.(. . .“~-,_. . . . . . . . . . . . . . ,:`. . . .. ./
. . . . . . /(_. . ”~,_. . . ..“~,_. . . . . . . . . .,:`. . . . _/
. . . .. .{.._$;_. . .”=,_. . . .“-,_. . . ,.-~-,}, .~”; /. .. .}
. . .. . .((. . .*~_. . . .”=-._. . .“;,,./`. . /” . . . ./. .. ../
. . . .. . .\`~,. . ..“~.,. . . . . . . . . ..`. . .}. . . . . . ../
. . . . . .(. ..`=-,,. . . .`. . . . . . . . . . . ..(. . . ;_,,-”
. . . . . ../.`~,. . ..`-.. . . . . . . . . . . . . . ..\. . /\
. . . . . . \`~.*-,. . . . . . . . . . . . . . . . . ..|,./.....\,__
,,_. . . . . }.>-._\. . . . . . . . . . . . . . . . . .|. . . . . . ..`=~-,
. .. `=~-,_\_. . . `\,. . . . . . . . . . . . . . . . .\
. . . . . . . . . .`=~-,,.\,. . . . . . . . . . . . . . . .\
. . . . . . . . . . . . . . . . `:,, . . . . . . . . . . . . . `\. . . . . . ..__
. . . . . . . . . . . . . . . . . . .`=-,. . . . . . . . . .,%`>--==``
. . . . . . . . . . . . . . . . . . . . _\. . . . . ._,-%. . . ..`\
Trial and error.
1
Please, keep this on topic >.>
1
So, er, I really don't know how to do this... I don't know Eclipse, and I have never coded before. I'm making this 100% from a tutorial, until I finish it, then I'll get more help, and learn.
1
Java Swing is now being taken over to JavaFX now in Java 8 +
1
JavaFX is awesome IMO.
And I agree with others, maybe you should learn basic Java before trying to make an sort of game. Even if you are going off of a tutorial...
And I agree with others, maybe you should learn basic Java before trying to make an sort of game. Even if you are going off of a tutorial...
1
How come you've called the "setMinimumSize()" method twice with the same arguments?
- Slendy
- Slendy
1
Also just noticed, you are closing off the Game class at line 12 but then you keep adding on fields and methods... why in the world hasn't the syntax checker screamed at you.
1
That error is caused when you don't have a main method...
That or, you need to specify the class to launch, but, make sure the aforementioned class contains a main method.
That or, you need to specify the class to launch, but, make sure the aforementioned class contains a main method.
1
Click to reveal
Are you using any frameworks/libraries?
I am using IntelliJ IDEA and cant remember how eclipses' GUI is but from the messages it looks like you haven't selected which class has the main method.
If you are using a library check the wiki for that, else select the class with the
I am using IntelliJ IDEA and cant remember how eclipses' GUI is but from the messages it looks like you haven't selected which class has the main method.
If you are using a library check the wiki for that, else select the class with the
public void main(String[] args) {}
methodEDIT:
Ah you are doing this totally wrong just read your code from your screenshots.
You are using javas swing packages as I see and it doesnt apear to have a main method.
Add in a method named main with a string array as arguments
public void main(String[] args){
}
The code in that method is the code that will run when the program is executed.
1
I said I have no previous coding experience. I really need your help though, guys.
1
k
1
what is that lol
1
I wouldn't suggest making a 2D game if you don't know what a main class is, lol
1
^^^^^^^^^
1
Lolz
1
not yet, but you just need to select a main class for it
1
Any luck?
1
1
Ok, I will try to fix that then
1
I tried your game. Running it had the same effects. If we can resolve those, then ill continue my tutorials i'm using.
1
Sent it
1
Oki doke. xDD
1
Hmm...I will just PM you the src code for my game, xD You can edit it
1
Ok, I know that error as well, I despise it...I just want it to go die in a hole and...I think you get it. I forgot how to fix that, let me go expieriment
1
Oh, that is not a problem with the code! xD Let me run you through this, just right click on the Java Project > Run As > Java Application
1
I used a tutorial to get this far, just to set up the JFrame. He didn't do that to run it, he did it through the debug run. Also, this error occurred when I did it.
1
[quote="gabe4356"]It would be a lot eaiser to help you if you just put the code in a spoiler.
Sorry, I put it in a image because I thought words that were highlighted automatically mattered. This is the code.'
[spoiler]package ca.vanzeben.adventure;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame
public class Game extends Canvas implements Runnable {
private static final long serialVersionUID = 1L;
}
public static final int WIDTH = 160;
public static final int HEIGHT = WIDTH / 12 * 9;
public static final int SCALE =3;
public static final String NAME = "Adventure!"
private JFrame frame;
public boolean running = false;
public Game() {
setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
frame = new JFrame(NAME);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(this, BorderLayout.CENTER);
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public synchronized void start() {
running = true;
new Thread(this).start();
}
public synchronized void stop() {
running = false;
}
public void run() {
while (running) {
System.out.printIn("Hello World");
}
}
public static void main(String[] args) {
new Game().start()
}[/spoiler]
Sorry, I put it in a image because I thought words that were highlighted automatically mattered. This is the code.'
[spoiler]package ca.vanzeben.adventure;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
import javax.swing.JFrame
public class Game extends Canvas implements Runnable {
private static final long serialVersionUID = 1L;
}
public static final int WIDTH = 160;
public static final int HEIGHT = WIDTH / 12 * 9;
public static final int SCALE =3;
public static final String NAME = "Adventure!"
private JFrame frame;
public boolean running = false;
public Game() {
setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
frame = new JFrame(NAME);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(this, BorderLayout.CENTER);
frame.pack();
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public synchronized void start() {
running = true;
new Thread(this).start();
}
public synchronized void stop() {
running = false;
}
public void run() {
while (running) {
System.out.printIn("Hello World");
}
}
public static void main(String[] args) {
new Game().start()
}[/spoiler]
1
It would be a lot eaiser to help you if you just put the code in a spoiler or something like this:
Click to reveal
INSERT CODE HERE
1
Help?