Results 1 to 8 of 8
- 05-08-2011, 04:10 PM #1
Member
- Join Date
- May 2010
- Posts
- 24
- Rep Power
- 0
netbeans can't find class in .jar file
HI,
I've imported a .jar file containing some classes.
(Libraries/r.click/Add Jar/Folder)
But when I use a class from .jar file, netbeans can't find it.
Do I have to every time drag the class java file into my project package?
Actually it runs from command line when I add a classpath to the .jar file, but in netbeans it won't, have to include the classes I need into the project.
- 05-08-2011, 05:01 PM #2
Senior Member
- Join Date
- Mar 2011
- Posts
- 261
- Rep Power
- 3
Importing your library into Netbeans isn't enough, you have to add it to your project as well.
-
You've got to change your project settings in netbeans so it will include the Jar file(s) on the build path. I know how to do this in Eclipse but not NetBeans, but the help files will tell you how.
- 05-08-2011, 05:13 PM #4
Member
- Join Date
- May 2010
- Posts
- 24
- Rep Power
- 0
Yes, but I didn't import a library. I imported a jar flie under:
Navigator/Projects/MyProjectName/Libraries
Imported it with a right click on Libraries/Add Jar/Folder
Isn't it imported into the project now?
Then I also have to manually find the classes I need from the jar file and copy the source into:
Navigator/Projects/MyProjectName/Source Package/package
- where my source files are
So it pretty much didn't import anything, I can just drag/copyPaste what I need from one folder to another folder in my project (really advanced :D)
P.S. I will post that into netbeans forum as well, thx
Adding one more line - I DO see the jar file under:
Project/r.click-properties/Libraries/Compile-time Libraries
So I really see no point what the problem is.Last edited by emosms; 05-08-2011 at 05:33 PM.
-
Have you added the jar file to the build path and imported the classes you needed that are in the jar file?
- 05-08-2011, 05:49 PM #6
Member
- Join Date
- May 2010
- Posts
- 24
- Rep Power
- 0
dont know where is the build path
- 05-08-2011, 06:01 PM #7
Member
- Join Date
- May 2010
- Posts
- 24
- Rep Power
- 0
Oops
Java puts the source into "Packages"
Seems like when there is no package defined - it puts them into <default package>
So, the .jar file has the class and source files into a "default package"
The netbeans project puts the source into a package with the same name as the project name.
Now I moved the source file out of the "package" and it automatically wrapped them into some "entity" called <default package> // or no package
And now the source files see the classes in the jar file :)
Maybe have to mess into the project xml files and alter the path to the library when I need to work with package different than the <default>
- 05-08-2011, 07:03 PM #8
Similar Threads
-
.jar file cant find main class
By eLancaster in forum New To JavaReplies: 3Last Post: 02-10-2011, 11:17 AM -
cannot find the class file when running the java command
By kulangotski in forum New To JavaReplies: 4Last Post: 01-18-2011, 11:34 AM -
Jar file could not find the main class
By Collinryans in forum New To JavaReplies: 3Last Post: 06-23-2010, 04:18 AM -
how to find class name when have only jar file?
By matvey in forum Java AppletsReplies: 9Last Post: 10-13-2009, 01:49 PM -
Able to find class file in WEB-INF/classes but not after add sub folders in class dir
By vitalstrike82 in forum Web FrameworksReplies: 0Last Post: 05-13-2008, 06:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks