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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:51:21+00:00 2026-05-18T11:51:21+00:00

I am having some issues running my compiled java code from the command line.

  • 0

I am having some issues running my compiled java code from the command line. I have written it and compiled it using the IntelliJ IDE (where everything runs fine if done within the IDE), but wish to now run it from the command line.

Compiling from the command like (using javac) also works fine, but running (with java) does not.

I am almost certain this is a classpath issue but cannot seem to fix it. From my searching prior to posting this I found a post telling me to run the “set PATH=\%PATH\%;”C:\Program Files\Java\jdk1.6.0_21\bin” command and then try running java. I have also tried various arguements I have found for -cp and -classpath. The error is :

Exception in thread "main" java.lang.NoClassDefFoundError: Share/class
Caused by: java.lang.ClassNotFoundException: Share.class
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: Share.class.  Program will exit.
  • 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-18T11:51:22+00:00Added an answer on May 18, 2026 at 11:51 am

    You’re doing:

    java -cp ... Share.class
    

    Do

    java -cp ... Share
    

    Or if it’s in a package

    java -cp ... path.to.Share
    

    You should not be supplying the class file as an argument, you should be supplying the fully qualified class name.

    If your class is in the current directory and uses the default (empty) package, it will just be

    java -cp . Share
    

    or

    java Share
    

    The classpath is not used to point to the java executable, it’s used to point to the various directories/jar files which contain your class files (at the root of the package structure).

    See also

    • java – the Java application launcher (manual for invoking java)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues using rails validation on a form. What I'm doing is,
I'm using SDL_Image to display a JPEG on screen and having some issues with
I am passing in a dynamic type into a method and having some issues
I installed scala 2.8.0 last night and I seem to be having some issues
I'm having some issues with the self parameter, and some seemingly inconsistent behavior in
I am working on a linux daemon and having some issues with the stdin/stdout.
I've been having some major issues with a layout I'm making specifically in Internet
I'm trying to compile and run a Java3D project on my mac and having
I have a PHP app built on Codeigniter 1.7.2, currently in production and live,
Summary: memcpy seems unable to transfer over 2GB/sec on my system in a real

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.