docmccoy
9th August 2011, 09:06 AM
Hi people,
I'm reading beautiful book "Thinkning in Java". I use Fedora Exlipse to handle the code, it works perfectly.
While later then I decided to learn howto compile without IDE in order to understand how packages work. I have read the book explanations and sure I'm familiar with creating and classes and packages as series of classes.
So I have done the following:
cd Documents/Java\ Development/ // go into development directory
mkdir ByHandLibrary // create folder for my project (or library)
cd ByHandLibrary
mkdir core // create folder for new package
cd core
create MainPoint.java file with the following text:
package core;
public class MainPoint {
public static void main(String[] args) {
System.out.println("It works!");
}
}
java MainPoint.java // compile source code
export CLASSPATH=/home/dave/Documents/Java\ Development/ByHandLibrary/ (is it okay?)
java MainPoint // run the program (MainPoint.class file has appeared due to the previous statement)
And boom:
[dave@heaven core]$ java MainPoint
Exception in thread "main" java.lang.NoClassDefFoundError: MainPoint
Caused by: java.lang.ClassNotFoundException: MainPoint
at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
Could not find the main class: MainPoint. Program will exit.
Thank you for any advice indeed!
---------- Post added at 11:06 AM ---------- Previous post was at 10:59 AM ----------
[dave@heaven core]$ java -classpath /home/dave/Documents/Java\ Development/ByHandLibrary/core/ MainPoint
does not help.
I'm reading beautiful book "Thinkning in Java". I use Fedora Exlipse to handle the code, it works perfectly.
While later then I decided to learn howto compile without IDE in order to understand how packages work. I have read the book explanations and sure I'm familiar with creating and classes and packages as series of classes.
So I have done the following:
cd Documents/Java\ Development/ // go into development directory
mkdir ByHandLibrary // create folder for my project (or library)
cd ByHandLibrary
mkdir core // create folder for new package
cd core
create MainPoint.java file with the following text:
package core;
public class MainPoint {
public static void main(String[] args) {
System.out.println("It works!");
}
}
java MainPoint.java // compile source code
export CLASSPATH=/home/dave/Documents/Java\ Development/ByHandLibrary/ (is it okay?)
java MainPoint // run the program (MainPoint.class file has appeared due to the previous statement)
And boom:
[dave@heaven core]$ java MainPoint
Exception in thread "main" java.lang.NoClassDefFoundError: MainPoint
Caused by: java.lang.ClassNotFoundException: MainPoint
at java.net.URLClassLoader$1.run(URLClassLoader.java: 217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 21)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 66)
Could not find the main class: MainPoint. Program will exit.
Thank you for any advice indeed!
---------- Post added at 11:06 AM ---------- Previous post was at 10:59 AM ----------
[dave@heaven core]$ java -classpath /home/dave/Documents/Java\ Development/ByHandLibrary/core/ MainPoint
does not help.