Netbeans:Importing existing code conundrum...

Thread Solved

Join Date: Jun 2008
Posts: 8
Reputation: suvirj is an unknown quantity at this point 
Solved Threads: 0
suvirj's Avatar
suvirj suvirj is offline Offline
Newbie Poster

Netbeans:Importing existing code conundrum...

 
0
  #1
Dec 15th, 2008
Hi,
I am kinda new to java netbeans...i have downloaded some java code which is n implementation of the algorithms in the book AI:A Modern Approach.

After extraction, the folder has bin, build, doc and src folders which hold various .class and .java files.

Now my problem is that i want to access these classes in another netbeans project. I tried using the template "project with exisiting sources", but i ended up with an "incorrect package" error all over.

Plss help....

Suvir
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,432
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Netbeans:Importing existing code conundrum...

 
0
  #2
Dec 15th, 2008
If you also have a .jar file of the classes in that download, you can just add it as a library to your project (from Project Properties window). The same would work for the folder containing the class files themselves.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 8
Reputation: suvirj is an unknown quantity at this point 
Solved Threads: 0
suvirj's Avatar
suvirj suvirj is offline Offline
Newbie Poster

Re: Netbeans:Importing existing code conundrum...

 
0
  #3
Dec 15th, 2008
Thats what doesnt seem to be happening.I added the *.class files' folder in the project properties.It returns an "incorrect package" error...what could be the possible reason...
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,181
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 481
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Netbeans:Importing existing code conundrum...

 
0
  #4
Dec 15th, 2008
There is a second possibility that suvirj uses a book that from chapter section to another chapter section change code little and he would like to keep original code, but on other hand he also want to apply changes as suggested in new exercises.
In this case create new project as the book ask you, then in Windows Explorer go to location of your original/previous project, copy files from src (source) folder to src folder of your newly created project directory.
In doing so you will have copy of previous exercise and you can continue with new one.

PS: You just posted reply, but this still does not make sense. Can you clarify issue with consideration of what I wrote above?
Last edited by peter_budo; Dec 15th, 2008 at 1:00 pm. Reason: Adding PS
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 8
Reputation: suvirj is an unknown quantity at this point 
Solved Threads: 0
suvirj's Avatar
suvirj suvirj is offline Offline
Newbie Poster

Re: Netbeans:Importing existing code conundrum...

 
0
  #5
Dec 15th, 2008
I am only trying to add the files that i downloaded into a blank project in NB.
Step 1) I created a new project in NB
Step 2) I right clicked project name->project properties->Libraries, and i added the directory which contains the class files.

But this doesnt do it. In the "project" window ( to the left by default) I see the names of all the classes that i want to add. BUT next to each one, I see a small red exclamation mark which says "Incorrect package" when i hover my pointer over it.

????
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,432
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Netbeans:Importing existing code conundrum...

 
0
  #6
Dec 15th, 2008
Well, if you had read the instructions for that project (which I found here in just a couple of clicks), you might have seen this part:
If you just want to use the classes, all you need to do is put the aima-java/build directory on your CLASSPATH.
Which means you should just add that folder to your Libraries under the Project Properties.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 8
Reputation: suvirj is an unknown quantity at this point 
Solved Threads: 0
suvirj's Avatar
suvirj suvirj is offline Offline
Newbie Poster

Re: Netbeans:Importing existing code conundrum...

 
0
  #7
Dec 15th, 2008
Ok. I had read that before but probably didnt do it properly. I made a new project and added the library as u said.

But still half of them are showing an "incorrect package" error.

What really is an "incorrect package" error?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,432
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Netbeans:Importing existing code conundrum...

 
1
  #8
Dec 15th, 2008
It means the package declaration in the file does not match the package structure on disk. Are you certain that you added the 'build' folder in the Libraries section using the "Add jar/folder" button? I downloaded the code and added that folder to my own project with no problems at all.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 8
Reputation: suvirj is an unknown quantity at this point 
Solved Threads: 0
suvirj's Avatar
suvirj suvirj is offline Offline
Newbie Poster

Re: Netbeans:Importing existing code conundrum...

 
0
  #9
Dec 15th, 2008
Umm...it worked...my mistake must have been that I was trying to add the build folder under the "Run" tab also...

Ok, so where do I add the .java files now?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,181
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 481
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Netbeans:Importing existing code conundrum...

 
0
  #10
Dec 15th, 2008
Do as per may previous post.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC