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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:09:25+00:00 2026-05-27T13:09:25+00:00

I know I’ll feel like a tard when I figure this one out. I’m

  • 0

I know I’ll feel like a tard when I figure this one out. I’m trying to do a very simple client/server and run it from the command line. It runs fine from Eclipse, but not from cmd. Here’s the client:

package com.mycompany.pdr.client;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.UnknownHostException;
public class SimpleClientSend {
public static void main(String[] args) {


    String host = "127.0.0.1";
    int port = 11048;
    String dataToSend = "HELLO SERVER";

    System.out.println("> Trying to connect...");
    System.out.println("> Opening connection to server [" + host + ":"
            + port + "]...");

    Socket socket1Connection;
    try {
        socket1Connection = new Socket(host, port);
        System.out.println("> Connected...");
        System.out.println("> Trying to write data... [ " + dataToSend + " ]");
        BufferedOutputStream bos = new BufferedOutputStream(
                socket1Connection.getOutputStream());
        /*
         * Instantiate an OutputStreamWriter object with the optional
         * character encoding. e.g. UTF-8
         */
        OutputStreamWriter osw = new OutputStreamWriter(bos, "US-ASCII");

        // Writing to server
        osw.write(dataToSend);
        osw.flush();

        System.out.println("> Writing to server done...");

        socket1Connection.close();

    } catch (UnknownHostException e) {
        System.out.println(e.getLocalizedMessage());
        System.out.println("Unknown Host. Please check if the server is running at the IP & port");
        //e.printStackTrace();
    } catch (IOException e) {
        System.out.println(e.getLocalizedMessage());
        System.out.println("Could not send data. Giving up.");
        //e.printStackTrace();
    }

    System.out.println("> End of connection...");
}

}

My directory structure is : (MyWorkspace)/myProject/com/mycompany/pdr/client
I run javac SimpleClientSend.java from inside the client folder, and I get a class file, no errors. I run java SimpleClientSend and I get a NoClassDefFound message:

Exception in thread "main" java.lang.NoClassDefFoundError:  SimpleClientSend (wrong name: com/iai/pdr/client/SimpleClientSend)

I’ve tried using -cp . when I run java to follow the suggestions of every other article out there(but what’s the point if . is already in my classpath?), I’ve tried running it from outside the client folder, everything just gives me the same error. In eclipse, all I had to do was paste the java files into a blank project and it ran. What am I doing wrong 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-05-27T13:09:25+00:00Added an answer on May 27, 2026 at 1:09 pm

    You need to specify the full name of your class (including package).

    java com.mycompany.pdr.client.SimpleClientSend

    It is important that the base of the structure for your class(es) is included in your class path. Normally . is included, so if you run the command above when your are in myProject it should work.

    If you are in another folder you should add the myProject to your class path, such as:

    java -cp …MyWorkspace/myProject com.mycompany.pdr.client.SimpleClientSend

    The … of course is since I don’t know your full path.

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

Sidebar

Related Questions

Know this might be rather basic, but I been trying to figure out how
I know this is a very simple question for you experts,but please forgive me.Im
I KNOW I did this in WP7 (not WP7.1) and I can't figure out
I know this is largely an opinion, but I'm interested if you have one
I know this is fairly subjective, but I'm diving into testing and learning about
I know this question has kind-a started religious wars in past and there might
I know that one of the differences between classes and structs is that struct
I know this is a stupid question, but I've looked for 45 mins now
I know very little about Agile but I wonder if there is any difference
I know of cufon and one other similar. But what is the best way

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.