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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:23:54+00:00 2026-05-17T22:23:54+00:00

I am trying to run a file from command line. The file is a

  • 0

I am trying to run a file from command line. The file is a .class file and is apart of a larger project that I compiled in Netbeans. I navigated to the .class file and ran

java MyFile

And I got:

Exception in thread "main" java.lang.NoClassDefFoundError: PersonTest/class
Caused by: java.lang.ClassNotFoundException: PersonTest.class
   at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
   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: PersonTest.class. Program will exit

Whats up with that? (I should mention that i’m running ubuntu)

  • 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-05-17T22:23:54+00:00Added an answer on May 17, 2026 at 10:23 pm

    You need to check this useful link java – the Java application launcher:

    By default, the first non-option
    argument is the name of the class to
    be invoked. A fully-qualified class
    name should be used

    So, you have to write the full qualified name of the class (this includes the package name).

    So, the right way to execute your command is this (from the root dir where your class files are stored):

    > java my.package.MyFile
    

    Also, make sure to include all the needed dependencies at the classpath (-cp) argument (check the referenced link).

    UPDATE: to include a classpath setting example:

    java -classpath C:\MyProject\classes;C:\MyProject\lib\utility.jar my.package.MyFile
    

    With this, the java runtime will search for the classes at the C:\MyProject\classes directory, and at the C:\MyProject\lib\utility.jar JAR file. You’ll need not only your class direct dependencies, but the dependencies needed by the referenced files (the whole tree).

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

Sidebar

Related Questions

I'm trying to run .class file from command line. It works when I manually
Java newbie. I am trying to run a java main class from cmd line
I'm trying to pass an argument from command line to a Java class. I
I am trying to run a java program from command line. I tried following
I'm trying to run a jar file from Java code, through exec(). The jar
I am trying run a program from a qmake .pro file which modifies the
I am trying to run a batch file automatically during a build from a
I'm trying to run a ruby file that will show git version of a
I'm trying to run a .exe file (that uses some other .dll files) with
I am trying to run a jar file using my command prompt (Windows XP)

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.