Results 1 to 4 of 4
  1. #1
    tetelee is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default [SOLVED]"Could not find the main class" for Linux Command Line Compile

    Hi all,

    I am compiling and executing a test JAVA app on my Ubuntu from command line. I have succeeded in compilation using "javac my_source_file.java" (I have set the CLASSPATH correctly so that it found the correct .jar file I am using). However, when I try to execute it by "java my_source_file", it complains about "Exception in thread "main" java.lang.NoClassDefFoundError: index" and "Could not find the main class: index. Program will exit."
    However, when I run it in Eclipse, it was working just fine. I googled and somebody said it is because Eclipse will recognize the main class in the project (or you can set it there). But how can I set it in command line compilation and execution?
    Thanks for any help!
    Last edited by tetelee; 08-25-2010 at 10:34 AM.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    tetelee is offline Member
    Join Date
    Aug 2010
    Posts
    2
    Rep Power
    0

    Default

    Sorry but it is now working. What I did was to move the files to another location than the Eclipse workspace and compiled like I pasted (and to export the CLASSPATH for each terminal).

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Replies: 5
    Last Post: 06-22-2010, 03:51 PM
  2. Replies: 6
    Last Post: 05-18-2010, 05:11 PM
  3. Replies: 1
    Last Post: 11-20-2009, 07:58 PM
  4. Replies: 1
    Last Post: 06-30-2009, 02:32 PM
  5. Replies: 12
    Last Post: 12-05-2008, 05:37 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
  •