Search code examples
javanetbeanssystemoutprintln

Why when I run wathever program in NetBeans, the part of system.out.println() affears as class unidentified


I just installed Netbeans and I wanted to write a small program that can read a value and then show it on screen. The thing is that whenever I add the sentence System.out.println() it marks an error and it says that the class is unidentified. I've tried to solve looking for it's library but I got no clue. Would you mind giving me a hand


Solution

  • You need to setup your project JDK. Here`s how to do it:

    To enable JDK support in the NetBeans IDE:

    • 1.Download and install JDK on your system.

    • 2.In the IDE, choose Tools > Java Platforms from the main menu.

    • 3.Click Add Platform and specify the directory that contains the JDK (e.g. on Windows, this is the JDK installation directory, default is C:\Program Files\Java\jdk_version).

    • 4.The directory that contains the Java platform is marked with the Java Platform icon icon.

    • 5.In the Platform Name step, verify that the default locations of the Platform Sources zip file and API documentation are valid.

    • 6.Click Finish to close the Add Java Platform dialog box.

    • 7.Ensure JDK is chosen in the Platforms list and click Close.

    Once you have registered JDK in the IDE, you need to configure your project to use this JDK for compilation, running, and debugging:

    • 1.Create a Java project. Choose File > New Project and select Java Application as the project type. Click Next.

    • 2.Type ProjectNameHere as the project name and specify its location.

    • 3.In the Files window, right-click the ProjectNameHere project's node and choose Properties > Libraries. On this tab, choose JDK from the list of Java Platforms.

    • 4.Switch to the Sources tab of the Project Properties window and choose JDK as the Source/Binary Format.

    • 5.Click OK to save changes. Your project is set to recognize new JDK language features.

    You can refer to this link: https://netbeans.org/kb/73/java/javase-jdk7.html