Results 1 to 3 of 3
  1. #1
    agouzoul is offline Member
    Join Date
    Apr 2008
    Rep Power

    Default Java command line

    Hello to everyone,

    I decided to post this thread in this forum and not in Eclipse because I am new to Java and this question is technically not an eclipse one :)

    So here is the question:

    I compile and run this program in Eclipse and it works perfect.

    I am trying to incorporate it in another application by means of a comand line interface ... the application has means of sending a command to a cmd command
    interpreter and executing it. When I try and test this on the command line I get the following error:

    Exception in thread "main" java.lang.NoClassDefFoundError: myclass (wrong name: com/example/java/swiss/myclass)

    I thought this could be due to my environment not being set-up correctly. So added the following to my CLASSPATH and PATH:

    C:\Work\Java Work Space\src\com\example\java\swiss;C:\Work\Java Work Space

    C:\Work\Java Work Space\TonerWebService\lib; <==== where the class (in a jar file) my program is calling is located
    C:\Work\Java Work Space\TonerWebService\lib\ ttpConnection.jar; <==== the jar itself
    C:\Work\Java Work Space\TonerWebService\classes\com\example\java\swi ss <==== where the compiled class (main) is located

    I also tried the following and get the same error.

    Java -cp "C:\Work\Java Work Space\TonerWebService\lib;C:\Work\Java Work Space\TonerWebService\lib\ ttpConnection.jar" myclass

    I also included -jar "<PATH TO JAR>" but without success.

    Do you have any idea as to where I am going wrong? Is there anything I am missing???

    Is there any where in Eclipse you can capture the java command line that the IDE executes to run myclass .. perhaps some log file or a way that this command line can be generated within the IDE??


  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    Classpath is the path to where your JDK instalation can be found. Not the working folder. Something like this,

    c:\programme\j2sdk1.4.2_08\jre\lib; .........

  3. #3
    agouzoul is offline Member
    Join Date
    Apr 2008
    Rep Power

    Default Classpath

    Many thanks Eranga...

    My class path already has the followings but did not incluce them in my previous pot:

    C:\Archivos de programa\Java\jre1.5.0_08\lib;
    C:\Archivos de programa\Java\jre1.5.0_08\bin

    So yes I have the path to the JRE included as well and get the same error.


Similar Threads

  1. Command line argument
    By denisatandi in forum New To Java
    Replies: 8
    Last Post: 10-16-2012, 11:37 PM
  2. calling linux command line in java
    By fangzhong in forum New To Java
    Replies: 0
    Last Post: 02-03-2008, 05:24 PM
  3. Exporting from the command line
    By o1121 in forum Eclipse
    Replies: 1
    Last Post: 08-09-2007, 07:29 PM
  4. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 12:23 AM
  5. Java Command Line Arguments In Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-19-2007, 09:45 AM

Posting Permissions

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