java - How to import a class from a package in a different folder? -


i new java. basic question packages. have small java project named "stacklist.java" in netbeans ide. it's package name stacklist. , has 4 different classes. 1 of them listnode.

now need listnode object in other project "queuelist.java".

directory structure stacklist->src->stacklist , queuelist->src->queuelist. both stacklist , queuelist @ same level.

and added folder(stacklist\src) in libraries of queuelist.java project. did "import stacklist.*;"

when run "clean , build project", getting this: "error: package stacklist not exist import stacklist.*;"

please suggest me.

for

package a.b.c; public class d;  package e; import a.b.c.d; public class e; 

you need

src\a\b\c\d.java src\e\e.java 

you might go maven, popular professional build infrastructure helps libraries internet , library versioning. , programming conventions.

for maven:

package a.b.c; public class d;  package e; import a.b.c.d; public class e; 

you need

src\main\java\a\b\c\d.java src\main\java\e\e.java 

developing 2 projects needs care. if 1 project gives library stacklist.jar need keep library builded date. ide takes shortcut, explicit use of library may yield version errors.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -