-2

I recently started making a game in eclipse, installed everything according to the guide but this error pops up.
error text:
Error: Could not find or load main class java
Caused by: java.lang.ClassNotFoundException: java
image
Arleady tried to reinstall java
The only thing i didn't tried is lauching it from cmd because I didn't understand the structure that Eclipse does.

The problem is that i don't have any class named "java", it may be predefined class so i have no idea why JVM can't find it
Any thoughts how to fix it?

code(single file):

package test;

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer ;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;

public class GameClass extends BasicGame {


    public GameClass(String title) {
        super(title);
    }

    public void init(GameContainer container) throws SlickException {

    }

    public void update(GameContainer container, int delta) throws 
        SlickException {
    }

    public void render(GameContainer container, Graphics g) throws 
        SlickException {
    g.drawString("Helle World!", 56, 50);
}

 public static void main(String[] args) throws SlickException {
AppGameContainer app = new AppGameContainer(new GameClass("Setup Test"));
app.setDisplayMode(800, 660, false);
app.start();

}
}

Run as -> Run configuration -> java application -> arguments and i put
java -Djava.library.path=<C:\Users\user\Downloads\slick>(libraries location) in VM arguments field

other setting i did was in Dependencies tab
UPD:
Main tab
Dependencies tab

Loginik
  • 1
  • 1
  • 2
    There is insufficient information in your question to say what the problem is. So I suggest that you read this: https://stackoverflow.com/questions/11235827 – Stephen C Jun 03 '22 at 23:31
  • 1
    For what it is worth, the only useful information I can glean from your question is that you are attempting to run a class called "java". I wonder why would a guide suggest that you call your Java program "java". I expect that it didn't, and that you have misread or misunderstood it. – Stephen C Jun 03 '22 at 23:35
  • *"The problem is that i don't have any class named "java", it may be predefined class so i have no idea why"* - Well the only way you can get `Caused by: java.lang.ClassNotFoundException: java` is if you / Eclipse are trying to run it like `java java`; i.e. with "java" as the class name. Note we can't see the "guide" you are using. And we can't see how you are trying to run the application in Eclipse; e.g. you the "run" or "debug" config for the app is set up. – Stephen C Jun 04 '22 at 01:15
  • By the way, did you take the time to (thoroughly) read the duplink and all of its answers? Did they tell you anything about what you might be doing incorrectly? – Stephen C Jun 04 '22 at 01:17
  • FWIW, there is no class called "java". The problem is that somehow you are *telling* Eclipse to run a class called "java" ... which does not exist. – Stephen C Jun 04 '22 at 01:22
  • Yes ... and what does the run config say that the name of the class to be run is? – Stephen C Jun 04 '22 at 02:14
  • You put "there"? Specifically what config field did you set that to? It looks like you might have put that into a run config field that is supposed to contain the class name!! – Stephen C Jun 04 '22 at 02:18
  • I put ```java -Djava.library.path=``` in VM arguments field to fix error "no lwjgl:64" – Loginik Jun 04 '22 at 02:40
  • I just realized that you can respond with comments, until now I was updating question every time. I posted images of other tabs i configured – Loginik Jun 04 '22 at 02:42
  • 2
    Well "java" should not be there. It is not a JVM argument. Remove it. What is happening is that those arguments are being passed to the `java` command *and it is treating the bogus "java" argument as the name of the class to run*!! And hence the exception saying that it cannot load the (non-existent) "java" class. – Stephen C Jun 04 '22 at 02:44
  • Looks like i got this error from an answer from [this discussion](https://stackoverflow.com/questions/30346632/java-error-no-lwjgl64-in-path) – Loginik Jun 04 '22 at 02:58
  • 2
    Yea ... I think you misinterpreted what the answer is saying in ^^^. The example in Jesper's answer is for how to do it when running from the command prompt. You are doing it from within Eclipse ... and that requires some adjustment, on your part. – Stephen C Jun 04 '22 at 03:00

0 Answers0