I'm following a very simple/basic tutorial that uses NetBeans. I installed it in my ubuntu 20.04.2 LTS via sudo apt install netbeans
and just started a new project with the "create new main class" checkbox marked. However, whenever I try to run my code I get the "javaapplication5.JavaApplication5 class wasn't found in JavaApplication5 project. The code I'm trying to run is a simple "Hello world":
package javaapplication5;
public class JavaApplication5 {
public static void main(String[] args) {
System.out.print("Hello world!");
}
}
I also tried right-clicking the project, selecting run, and selecting the class I want, but the class doesn't even show up. What am I doing wrong here?
Edit: here is the message displayed in the output after i try to build the project:
ant -f /home/marco/NetBeansProjects/JavaApplication6 -
Dnb.internal.action.name=rebuild clean jar
init:
deps-clean:
Updating property file:
/home/marco/NetBeansProjects/JavaApplication6/build/built-
clean.properties
Deleting directory /home/marco/NetBeansProjects/JavaApplication6/build
clean:
init:
deps-jar:
Created dir: /home/marco/NetBeansProjects/JavaApplication6/build
Updating property file:
/home/marco/NetBeansProjects/JavaApplication6/build/built-
jar.properties
Created dir:
/home/marco/NetBeansProjects/JavaApplication6/build/classes
Created dir: /home/marco/NetBeansProjects/JavaApplication6/build/empty
Created dir:
/home/marco/NetBeansProjects/JavaApplication6/build/generated-
sources/ap-source-output
Compiling 1 source file to
/home/marco/NetBeansProjects/JavaApplication6/build/classes
compile:
Created dir: /home/marco/NetBeansProjects/JavaApplication6/dist
Copying 1 file to /home/marco/NetBeansProjects/JavaApplication6/build
Building jar:
/home/marco/NetBeansProjects/JavaApplication6/dist/JavaApplication6.jar
To run this application from the command line without Ant, try:
/usr/lib/jvm/java-11-openjdk-amd64/bin/java -cp
/home/marco/NetBeansProjects/JavaApplication6/dist/JavaApplication6.jar
javaapplication6.JavaApplication6
deploy:
jar:
BUILD SUCCESSFUL (total time: 1 second)
I have managed to create a main class and compile the project by using apache netbeans instead of the netbeans i installed via sudo apt install. I have no idea what is the difference between the two of them, though.
Edit: as asked below, the jdk version i get via java --version is:
openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment (build
11.0.10+9-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
and my defective netbeans is Apache Netbeans IDE 10.0