Cant run java classfiles through command line.

This is a discussion on Cant run java classfiles through command line. within the Tech Board forums, part of the Community Boards category; I use eclipse to compile and run my programs but when I try to run them via the command line ...

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    Cant run java classfiles through command line.

    I use eclipse to compile and run my programs but when I try to run them via the command line I get "Exception in thread "main" java.lang.NoClassDefFoundError:"

    Now first thing's first, I did look up the problem which all pages pointed to the -classpath option not being set. I properly ran the program with

    java -classpath . CipherTest -e FEATHER PlainFile.txt Encrypt.txt

    but I still get the error. Anyone knows if this is some thing with eclipse?

    The entire error is

    Code:
    C:\Documents and Settings\251070\My Documents\Java\Encryption\bin\Encryption>jav
    a -classpath . CipherTest -e FEATHER PlainFile.txt Encrypt.txt
    Exception in thread "main" java.lang.NoClassDefFoundError: CipherTest (wrong nam
    e: Encryption/CipherTest)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$000(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    Last edited by indigo0086; 05-08-2008 at 11:01 AM.

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Go up one directory, then run

    java -classpath . Encryption.CipherTest -e FEATHER PlainFile.txt Encrypt.txt

    You have to respect the package hierarchy and Java's class loading mechanism when running applications.

    On a side note, it's a pretty much universal convention that package names are all lowercase.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    ahh, I somehow forgot that I was using packages....odd. I changed the package to lower case btw. Thanks.

    This reminds me not to take up Encryption as a hobby.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What language did they make Java in?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 07-03-2005, 04:18 PM
  2. C or Java as a first language
    By CorJava in forum A Brief History of Cprogramming.com
    Replies: 34
    Last Post: 10-23-2002, 05:12 PM
  3. C/C++ Vs Java
    By Spectrum48k in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 10-21-2002, 09:06 PM
  4. Java the backbone of web-industry ?
    By Zeeshan in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-10-2002, 10:35 PM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21