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

  • Home
  • SEARCH
  • 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 7715739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:27:48+00:00 2026-06-01T02:27:48+00:00

I have Simple java program named MainController.java. Wehn I try to compile it from

  • 0

I have Simple java program named MainController.java. Wehn I try to compile it from the directory where I have stored my MainController.java file by writing javac MAinController.java, it compiles properly and generates MainController.class file in the same directory. Now
1) when I try to run the file by writing “java MainController”, it gives me

Exception in thread "main" java.lang.NoClassDefFoundError: MainController (wrong name: cased/test/MainController)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    Could not find the main class: MainController. Program will exit.
    ragini@ragini-ThinkPad-W500:~/workspace/Test/src/cased/test$ 

I know there is some problem with my classpath. How do I set ? I want that when I run command “java MainController” from the directory where there is Maincontroller.class file, it should run it. I dont want to pass -cp parameter to java command each time I want to run it.

For jvm info I ran “java -version” and it displays following:

java version “1.6.0_22”
OpenJDK Runtime Environment (IcedTea6 1.10.6) (6b22-1.10.6-0ubuntu1)
OpenJDK Server VM (build 20.0-b11, mixed mode)

Please tell me how to set classpath variable and what it to set for above jvm.

Thank you in advance.

  • 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-01T02:27:49+00:00Added an answer on June 1, 2026 at 2:27 am

    You need to add the package name when you execute MainController. From your ~workspace/Test/src directory, execute the following:

    javac cased/test/MainController.java
    java cased.test.MainController
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Java program which reads a file directory and outputs a
I have been trying to call a mapreduce job from a simple java program
I have a simple Java program that reads in a text file, splits it
i found many related questions here. I have a simple java program . it
I have avery simple program which uses MediaPLayer. I am new to java and
I have a simple Java class that I need to serialize to be stored
I have a simple java project (adapted from the example here ), which is
I am developing a simple Java program to create an Excel file using (Apache
I have a simple log4j.property file and a simple program that use log4j. But
I am trying to call native executables from java program. I have three exe

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.