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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:11:40+00:00 2026-05-15T02:11:40+00:00

I have a client/server program that attempts to send and receive an object. There

  • 0

I have a client/server program that attempts to send and receive an object.

There are three packages: server, client and shared
shared contains only the Message class

I put Message.java from shared package into the same folder as calcclient package source files and calcserver package source files.

I compile using the line: javac -classpath .; (long list of client or server.java files) Message.java
They can compile.
Then I change directory up one level and ran with: java -classpath .; .Main

When I use Netbeans to run, the entire program works as per normal. But not if I run from command line. If its executed through command line, the program will work until it needs to use the Message object. Then it will show a NoClassDefFoundError

Am I putting the right files at the right places? How do I get the program to find shared package through command line?

  • 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-15T02:11:40+00:00Added an answer on May 15, 2026 at 2:11 am

    The files are not in the right place. The Message class belongs to a different package so it shouldn’t be living with the other classes. From http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html :

    User classes are classes which build
    on the Java platform. To find user
    classes, the launcher refers to the
    user class path — a list of
    directories, JAR archives, and ZIP
    archives which contain class files.

    A class file has a subpath name that
    reflects the class’s fully-qualified
    name. For example, if the class
    com.mypackage.MyClass is stored under
    /myclasses, then /myclasses must be in
    the user class path and the full path
    to the class file must be
    /myclasses/com/mypackage/MyClass.class.
    If the class is stored in an archive
    named myclasses.jar, then
    myclasses.jar must be in the user
    class path, and the class file must be
    stored in the archive as
    com/mypackage/MyClass.class.

    You have a couple of options:

    The best solution is to take the time to learn Ant. Netbeans projects are built with Ant, which is a really great feature of Netbeans in my book, and you can open up the build.xml in your project and find a reasonably well commented description of what Netbeans does to build your project. And really I don’t think there would be many places around that run builds from the command line so learning something like Ant would be a great help.

    The next level down in sophistication would be to manually build a Jar for your shared package and put it somewhere on the classpath.

    The most basic approach is just to compile the java files into class files and put them in the appropriate directory reflecting the package name as explained in the quote above.

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

Sidebar

Ask A Question

Stats

  • Questions 424k
  • Answers 424k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I would recommend anyone starting with SharePoint now to start… May 15, 2026 at 11:55 am
  • Editorial Team
    Editorial Team added an answer It could well be your Apache configuration file. When Passenger… May 15, 2026 at 11:55 am
  • Editorial Team
    Editorial Team added an answer browser has no DNS cache. your operating system's tcp stack… May 15, 2026 at 11:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.