Java main class not found
Hello,
I'm still relatively new in Java and have now entered a small problem. I have my first programs on the command line and run, which has so far everything works. Now I use NetBeans with a little Hello World program I wrote:
Code:
package helloworld;
public class Main (
/ **
* @ param args the command line arguments
* /
public static void main(String[] args) (
System.out.println("Hello World!");
)
)
But the code is not compiling , even I have tried it manually to run it but no success. Any more help regarding this topic is appreciated. Thank you.
Re: Java main class not found
You will need to do this
Code:
javac helloworld / Main.java compile
and
Code:
helloworld.Main java call.
The folder structure must be correct here (Folder = Java package). If you do not know the basics that is the core java then I would recommend you to that first.
Re: Java main class not found
I have the file now with NetBeans trial times as.jar packed. Now when I run (with the javaw.exe on Windows), spits me the "Could not find the main class: PATH \ dist \ hello world.jar. Program will exit "from. PATH \ dist java hello world.jar is the error message from my first post accordingly. PATH \ dist java -jar hello world.jar works, in the MANIFEST.MF
Code:
Main-Class: helloworld.Main
I guess the solution is equally simple? Any help is appreciated.
Re: Java main class not found
For this
Quote:
I have the file now with NetBeans trial times as.jar packed. Now when I run (with the javaw.exe on Windows), spits me the "Could not find the main class: PATH \ dist \ hello world.jar. Program will exit "from. PATH \ dist java hello world.jar is the error message from my first post accordingly. PATH \ dist java -jar hello world.jar works, in the MANIFEST.MF
you can do the following, just issue the following command in the terminal and if you are in linux be sure you have set the environment variables correctly.
Code:
javaw -jar hello world.jar ?
I hope this will help you.
Re: Java main class not found
Code:
javaw -jar hello world.jar
There were no error message yet Hello World! out.
But
Code:
java -jar hello world.jar
works as said. You can.jar files but usually just double-click Start. And that does not work even. I would not go any time via the console.
Re: Java main class not found
javaw is for the only run of applications with GUI control. Therefore, the program displays the console output to none. If you have windows have views in Tools-> Folder Options> File Types you see. There you can find the extension jar java link.
Re: Java main class not found
I have already. .jarfiles are associated with the javac.exe correct (it?).
For others.jar file that works, anyway. Not for my own. Whether with or without GUI.