If you use Eclipse to build and run your code then Eclipse manages your CLASSPATH. I think the confusion here arises due to CLASSPATH. Click 'Add Class Folder.' check the box for UtilBuild (the default location for the. In Eclipse, right-click on the project you were working on (the one where you couldn't get that blasted print() method to work!) Click Properties and Java Build Path->Libraries.If not, go to Project and click 'Build Automatically'. You will probably already have the 'Build Automatically' option checked.Chose the 'Copy Files' option and hit 'OK'. Select all the files in the net\mindview\util folder and drag them to the package under UtilBuild in Eclipse.Here you will find all the source code (.java) files for util. Navigate within the unzipped Thinking In Java (TIJ) folder to TIJ->net\mindview\util.Right-click on UtilBuild in the PackageExplorer window and click New->package. Chose the option "Use project folder as root and click 'Finish'. I solved it by following the steps below: If you have any questions please ask Ill get back to you as soon as I can. The Statement::::: .print("this stinks") is the fully qualified print statement and it does not throw an error but it does totally defeat the purpose of the print.java file. The method print(String) is undefined for the type Hello2 at Hello2.main(Hello2.java:6) The method print(String) is undefined for the type Hello2Īnd if I try to run it the error I get is:Įxception in thread "main" : Unresolved compilation problem: But the the print statement does, the only way to make the print statement work is to use its fully qualified name. Now the immport statement no longer gives me an error. Then I imported the file system and selected the the folder. Ok I have tried to get this working as you said, I have started a new project and I removed the static from the import statement, I then created a new source folder, then I created a new package in the source folder. I have searched this site and others and am just not having any luck.Īny help with this or sugestions are welcome and very appreciated. I know I am not the only one that has had this problem I have seen other questions about it on google searches and they were also asking about the Thinking In Java book. java files at start up so when I need them for the exercises in the book they will be there and work for me, or just an easy way to make them work everytime. What I need is a way to have eclipse load all these. I did that by creating a new source folder then making a new package in that foldeer then importing the print.java file into the package.īut the next time I try the same thing it does not work for me. I have been able to make one of the files work, the print.java file I gave the listing for in this message. I have tried a few other things but cant remember them all now. I have tried to add them as libraries and i have tried importing them into a package in a source file in the project. I have tried to add the directory to the classpath, but that seems to only work if you are using the JDK compiler. I have been trying to get these to work, but with only limited success, The autor uses another 32 of these packages through the rest of the book. The Eclipse IDE says that the class print() does not exist for the class HelloWorld. On this staement the Eclipse IDE says it cannot resolve net The error I get the most is in the statement. qualifiers, using Java SE5 static imports: Print methods that can be used without This is the contents of print.Java //: net/mindview/util/Print.java This is an example of the code in the book. However the author did not use Eclipse and this is where the problem commes in. The author uses his own packages to reduce typing. I am trying to learn from the book Thinking in Java vol4.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |