-2

HelloWorld.java

package DiscordBunkerOnlineBot;

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("dasdasdasdasdasdasd");
    }
}

I have problem with Error:

Could not find or load main class HelloWorld Caused by: java.lang.ClassNotFoundException: HelloWorld

I don't know how decide it.

I wrote:

jar cfe HelloWorld.jar HelloWorld HelloWorld.class

To create a .jar file

I tried writing:

jar cfe HelloWorld.jar mypackage.HelloWorld HelloWorld.class

It didn't help.

I tried to create a new project, it worked, but I want that to work on my main project.

Compo
  • 36,585
  • 5
  • 27
  • 39
  • 1
    Images of text are [not well received](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors) here. Please edit your question to show your code as text. – Old Dog Programmer Aug 03 '23 at 23:11
  • On the other hand, you might want to [search](https://stackoverflow.com/search?q=%5Bjava%5D++could+not+find+or+load+main+class) to see if this question has [already been answered](https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean). If the question gets down votes, it is probably because other users believe you didn't do that. Please take the [tour](https://stackoverflow.com/tour), see [How to Ask a Good Question](https://stackoverflow.com/help/how-to-ask). – Old Dog Programmer Aug 03 '23 at 23:12
  • Your class is in a package. Your jar layout needs to reflect that. – tgdavies Aug 03 '23 at 23:16
  • 1
    *And i wrote "jar cfe HelloWorld.jar HelloWorld HelloWorld.class" that create .jar file* Where did you do that - in the terminal? If so, what was the prompt, and what did you do *before* that? Hint: learn to copy and paste from a terminal when you post code here – g00se Aug 03 '23 at 23:34
  • How did you try to *run* the Java application. 'Cos the error message is saying that you (somehow) told it to run `HelloWorld` but the actual class name is `DiscordBunkerOnlineBot.HelloWorld` in the source code is. It seems to me that you have made a number of mistakes ... and you haven't given us anywhere like a complete description of what you actually did. – Stephen C Aug 04 '23 at 08:42

0 Answers0