Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8226403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:45:23+00:00 2026-06-07T15:45:23+00:00

Im using Java SDK 1.7 on Windows 7 via cmd.exe . Up until a

  • 0

Im using Java SDK 1.7 on Windows 7 via cmd.exe . Up until a few hours ago everything was working correctly when suddenly I was unable to run my compiled class files, consistently presented with the error in the title.

I seem to be able to compile my My.java file however I am unable to run the resulting class file (My.class). I am constantly given the error “Error: Could not find or load main class My.class”. I have tried this with multiple other class files all resulting in the same problem.

My ‘Path’ environment variable is set to “C:\Program Files (x86)\Java\jdk1.7.0_05\bin” if you were wondering

I have tried reinstalling, creating and setting a classpath variable (no luck), and even directly using the

java -cp . My.class

command.

I have tried these posts all to no avail, hence why I’m posting:

Error: Could not find or load main class

Error: Could not find or load main class- Novice

Could not find or load main class

Java 1.7.0_03 Error: Could not find or load main class

If it makes any difference my code is :

import javax.swing.JOptionPane;

class My {
    public static void main(String[] args) {
       final double x = 3.2;
       int i = (int)x;
       double m = 0;
       if (x < 4) {
          String saySomething = JOptionPane.showInputDialog(i);
          System.out.println(saySomething);
        }
       else {
          String saySomething = JOptionPane.showInputDialog(i);
          System.out.println("Hello World");
        }
       while (m < 10) {
            System.out.print(" While Loop ");
            m++;
        };
       for (i=1; i < 10; i++) {
           System.out.println("For Loop");
        };

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:45:25+00:00Added an answer on June 7, 2026 at 3:45 pm

    You should specify the classname instead of the file of the class to load. The difference is a simple matter of removing the .class extension.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set some custom AWS CloudWatch metrics using the Java SDK. I
i am using a third part SDK with my java application.The providers of sdk
I found this Is Sun Java really necessary for using Android SDK on Ubuntu
Using java If I store windows paths in a h2 database, and then try
I'm using android-mips-ndk-r5b-windows and latest sdk , I'm targeting Android 2.2 cygwin 1.79 the
I have java SDK 7 installed and i am using Eclipse 3.7.1 Indigo. When
Android SDK Manager complains WARNING: Java not found in your path. Instead of using
I'm beginner in Java Android developing. I'm using Eclipse SDK 3.6.1 version. I have
I'm working on an Android App using the Android SDK for Eclipse as well
My question concerns using aidl.exe (on a Windows system) from the command line. This

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.