Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error: Could not find or load main class

frank.anelliaFeb 9 2016 — edited Feb 9 2016

Hello,

I'm new to Java and I am using JDK 1.8.0_72.  I'm attempting to execute a .class file but I'm receiving the following error:

c:\Program Files\Java\jdk1.8.0_72\bin>java c:\java\GalToLit.java

Error: Could not find or load main class c:\java\GalToLit.java

I have set the CLASSPATH, PATH, and JAVA_HOME variables:

set PATH=C:\Program Files\Java\jdk1.8.0_72\bin

set CLASSPATH=C:\Program Files\Java\jdk1.8.0_72\lib

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_72

As I mentioned, I am new to Java and been searching the web for help in troubleshooting and nothing seems to work.  The basic code is:

  1. class GalToLit { 
  2.   public static void main(String args[]) { 
  3.     double gallons; //holds the number of gallons 
  4.     double liters;  //holds the number of liters 
  5.      
  6.     gallons = 10; //start with 10 gallons 
  7.     liters = gallons * 3.7854; // convert to liters 
  8.      
  9.     System.out.println(gallons + " gallons is " + liters + " liters."); 
  10.   } 

Please let me know if I need to provide more information. Thanks in advance for everyone's help.

Frank

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 8 2016
Added on Feb 9 2016
0 comments
1,405 views