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 7877391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:21:17+00:00 2026-06-03T03:21:17+00:00

Following program runs fine with Netbeans IDE but when i try to run from

  • 0

Following program runs fine with Netbeans IDE but when i try to run from command prompt i get

Exception in thread "main" java.lang.NoClassDefFoundError: Gcd (wrong name: algo
rithms/Gcd)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

package algorithms;

public class Gcd {

public static int ComputeGcd(int number1, int number2){
    if(number2 == 0){ return number1;}
    else{
         int remainder = number1 % number2;
         return ComputeGcd(number2,remainder);
    }
}


public static void main(String[] args) {

    int a = 32;
    int b = 12;
    System.out.println(ComputeGcd(a,b));

} 

}

enter image description here

  • 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-03T03:21:20+00:00Added an answer on June 3, 2026 at 3:21 am

    You should be in the src directory, running these commands:

    ...\src> javac algorithms\Gcd.java
    ...\src> java algorithms.Gcd
    

    (You don’t have to compile from that directory, but I would suggest you do so.)

    The java command takes the fully-qualified class name, which includes the package name.

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

Sidebar

Related Questions

Not too sure what to make of this, but program runs just fine in
My OpenCV CUDA program runs fine using a single NVidia 580GTX, but when using
I have written a small program in WindowsXP-python-pygame. It runs fine when I run
i get a bad_access error when i try to run my program, normally i
The following C++ program compiles and runs as expected: #include <stdio.h> int main(int argc,
In the following program, DummyMethod always print 5. But if we use the commented
I have a C program which compiles and runs fine under Linux without any
I am using Netbeans IDE 7.1.1 on ubuntu 11.10, when I try to create
The following program turns off the monitor. It sometimes crashes when I run it,
I am running the following java program in the Eclipse IDE: import java.net.*; import

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.