2

I am new to Java, but have some programming experience. I am reading a book on how to program in the Java language. My progress is impeded by my lack of knowledge with NetBeans and Java. My particular problem is that I am not seeing proper output in my output box. Regardless of the code.

Here is an example. I am sure I am missing a minor detail:

public class Weather
{
    public static void main(String[] arguments)
    {
        float fah = 86;
        System.out.println(fah + " degrees Fahrenheit is ...");
        //To conver fahrenheit to Celsius
        //Begin by subtracting 32
        fah = fah - 32;
        //divide the answer by 9
        fah = fah / 9;
        //multiply that answer by 5
        fah = fah * 5;
        System.out.println(fah + "degree Celsius is ...");

        float cel = 32;
        System.out.println(cel + "degress Celsius is ...");
        //To convert Farhenheit to celsius
        //begin by multiplying 9
        cel = cel * 9;
        //divide answer by 5
        cel =cel / 5;
        //add 32 to the answer
        cel = cel + 32;
        System.out.println(cel + "degrees Farenheit");

        }
}

OUTPUT BOX:

run:
Error: Could not find or load main class weather.Weather
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Leigh
  • 28,765
  • 10
  • 55
  • 103
Ross P.
  • 21
  • 1
  • 1
  • 3

3 Answers3

8

Close netbeans and then delete this directory C:\Users\Your name here\AppData\Local\NetBeans\Cache

Start Netbeans again and let it read the project.

Test project. Run project. It should work fine.

Community
  • 1
  • 1
Shubham Das
  • 1,257
  • 11
  • 10
0

I had the same problem and was able to fix it by setting the paths via cmd line:

cd C:\Program Files\Java\jdk*version*\bin>cd\
set path="C:\Program Files\Java\jdk*version*";
set classpath="C:\Program Files\Java\jdk*version*\lib\rt.jar";
TaylorJ
  • 41
  • 3
0

This worked for me (Java 8 on Netbeans, June 2019): File > Project Properties > Run > Application Class > Browse > and try a different application class entry

Ron Pitts
  • 1
  • 2