1
votes

I recently installed Netbeans 8.2 with JDK 8 on Windows 7 Enterprise 64-bit OS. Started the installation with jdk-8u131-windows-x64.exe, which was successful. After that tried to install netbeans-8.2-javase-windows.exe, which gave me error stating could not find JDK. After searching over the internet I could get Netbeans to install from command prompt with netbeans-8.2-javase-windows.exe --jdkhome "C:\Program Files\Java\jdk1.8.0_131", Netbeans8.2 installation was successful. Wrote a simple helloapp program: package helloapp;

public class Helloapp {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    System.out.println("hello");
}

}

When I run this project by any means Run Main project, F6, right click run file gives me output as :

run: BUILD SUCCESSFUL (total time: 0 seconds).

I have worked with previous version 8.1, and have never had problem. Wonder what is missing here. Can someone tell me what I might be missing here.

2
You may want to be a little clearer as to what you are expecting to happen. And what is the value of %JAVA_HOME%? - dcsohl
I am expecting "hello" to be printed to output. I am sorry how do i check %JAVA_HOME% ? - CuriQ
echo %JAVA_HOME% in a Windows Command Prompt window. - dcsohl
c:\windows\system32> echo %JAVA_HOME% gives %JAVA_HOME%. Is that ok , or is there something wrong? - CuriQ
Java uses the JAVA_HOME environment variable to figure out where all its component bits are. It may be that Netbeans, with the --jdkhome flag, has that all sorted out (I'm no Netbeans expert); however I find things generally work better with JAVA_HOME properly set. So set the variable (Windows Control Panel > System > Advanced > Environment Variables); the result of echo %JAVA_HOME% should print out C:\Program Files\Java\jdk1.8.0_131 - dcsohl

2 Answers

0
votes
  1. Make Sure that the class is not in the "default package". It should lie in the project's package.

  2. main method should be having the correct lines which are to be executed.

0
votes

Right click on the class and add it to the classpath. Usually you should be able to Right-Click and then Run as...