CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: How to include JAR file in a java program that is being executed by command line

  1. #1
    Join Date
    Mar 2015
    Posts
    2

    How to include JAR file in a java program that is being executed by command line

    I saw similar posts to this after searching in Java forums, but I tried all suggested answers there and they didn't work out (maybe I did something wrong). I have a java project with the following folders:

    bin
    src

    in the bin folder, I have few folders with .class files in them (compiled the project with eclipse, now just need to run it with command line). These are the folders inside bin:

    client
    game
    protocol
    threadPerClient
    tokenizer

    I also added the jar file (gson-2.2.1) to the bin folder. My main class is at threadPerClient folder, and this class name is MultipleClientProtocolServer. The main class get an int as a parameter. These are the commands that I tried to run via command line, from bin folder:

    1.
    Code:
    java -cp gson-2.2.1.jar threadPerClient.MultipleClientProtocolServer 4000.
    And I got for that:
    Code:
    Error: Could not find or load main class threadPerClient.MultipleClientProtocolServer
    2.
    Code:
    java -cp threadPerClient/:./ MultipleClientProtocolServer 4000
    And I got for that:

    Code:
    Error: Could not find or load main class MultipleClientProtocolServer
    3.
    Code:
    java -cp threadPerClient;. com.example.MultipleClientProtocolServer 4000
    And I got for that:

    Code:
    Error: Could not find or load main class com.example.MultipleClientProtocolServer
    What am I doing wrong?

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,858

    Re: How to include JAR file in a java program that is being executed by command line

    Norm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)