Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
package related questions
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Xiaoshen Li, post: 641613"] Dear All, I am learning package name and have been puzzled a lot. I have asked similar questions before, based on the replies, I have made some progress. *****************WHAT I CAN MAKE IT WORK:************************ (No CLASSPATH environment was set) In the directory ~/programming/java/Tools/ I have a java file SavitchIn.java with the line on the top: package Tools.SavitchTools; Compiling this file generate a class as: ~/programming/java/Tools/classes/Tools/SavitchTools/SavitchIn.class (Now still working at ~/programming/java/Tools/). A file Test.java with a import line on the top: import Tools.SavitchTools.SavitchIn; javac -classpath ./classes/ Test.java works great. (Question 1: why the generated Test.class is not put in the current directory, instead is in ./classes ?) Anyway, java ./classes/Test Works great. *******************WHAT I CANNOT MAKE IT WORK******************** If I am working in a far away directory ~/programming/java/other_projects/test_package/ Same Test.java file including the same import statement: import Tools.SavitchTools.SavitchIn; javac -classpath ./../../Tools/classes Test.java No error message at all. Test.class was generated and put in the current directory. (Question 2: why this time not put in ./classes, instead put in the current directory? ./classes exists.) java Test get error messages: Exception in thread "main" java.lang.NoClassDefFoundError: Tools/SavitchTools/SavitchIn at Test_Package.main(Test_Package.java:8) My guess is linking problem. Question 3: why executing failed? How to make it work? Thank you very much for your help. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
package related questions
Top