So I made a project with packages in Eclipse. I have a few classes all in same package com.example.parser. In Eclipse everything works fine. So I wanted to run one of the class from command line. The java/javac PATHs are set correctly and work normally if no packages are there. The file structure looks like this:
~Project/bin/com/example/parser/*.class (all class files)
~Project/src/com/example/parser/*.java (all source files)
So in command line I go to ~Project/bin/com/example/parser To mention OS: Windows 7 Pro The command java ClassToRun gives
Exception in thread "main" java.lang.NoClassDefFoundError: ClassToRun (wrong name:
com/example/parser/ClassToRun) at ... (stack trace)
So I googled a bit and got to conclusion this is the correct command: java -cp .;~Project/bin ClassToRun Now I get this:
Error: Could not find or load main class ~Project/bin
So I could not solve this... any one can help a bit? PS: Forgot to mention the "/" should be "\" and the "~" stands for the abs path infront. Oh yeah and I just update to jdk 1.7...