Solved

Can't add jar to NetBean

Posted on 2007-03-26
20
1,796 Views
Last Modified: 2013-12-14
Dear Experts,
Im trying to use NetBean 5.5 to evaluate it. Seems great but I already got a problem that annoying me. I got Apache Tomcat installed on my test computer. If I go under "Tools-Server Manager" I see Tomcat. In order to compile my servlet I added under "Library Manager" a new library with the button "New Library" I wrote Servlet in the text box and then using the "Add JAR/Folder" I add the classpath & the source giving it the path %NETBEAN%enterprise3\apache-tomcat-5.5.17\common\lib and %NETBEAN%enterprise3\apache-tomcat-5.5.17\common\lib\servlet-api.jar then I open a servlet class & it was plenty of red cross telling me "package javax.servlet.* does not exist" over the import javax.servlet  so I did "Source-Fix Imports" but nothing change. What Im missing??

Thanx in advance
Roberto
0
Comment
Question by:gokyo66
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 7
  • 2
  • +1
20 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 18791556
Shouldn't that be

%NETBEAN%\enterprise3

?
0
 

Author Comment

by:gokyo66
ID: 18791603
yep sorry I forgot a backslash but unfortunately is not that the problem...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18791614
Are you browsing to the directory through the GUI or typing the path in?
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:gokyo66
ID: 18791641
no Im browsing thru the GUI, I tried also givin the path %TOMCAT%\common\lib, but the problem still there
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18791696
It comes with a Servlet library doesn't it?

Why are you adding a new one?
0
 

Author Comment

by:gokyo66
ID: 18791706
Good question Tim, first time when I install it, I didn't do anything (I mean I didn't add any library) but then open my servlet and seeing that was plenty of error I thought that the API for Servlet was missing so I install it, that's why...
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18793467
>> "Add JAR/Folder" I add the classpath & the source giving it the path %NETBEAN%enterprise3\apache-tomcat-5.5.17\common\lib

That won't add the JARs in that folder - you need to add them individually.
0
 

Author Comment

by:gokyo66
ID: 18793945
in the classpath I added %NETBEAN%enterprise3\apache-tomcat-5.5.17\common\lib
in the source I added %NETBEAN%enterprise3\apache-tomcat-5.5.17\common\lib\servlet-api.jar
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18794075
Do you mean Classpath of the system? Netbeans uses its own classpath....

>> %NETBEAN%enterprise3\apache-tomcat-5.5.17\common\lib

You're again missing a \ after NETBEAN% BTW. And as I told you, you need to add the JARs individually to your project's build path, not the directory.
0
 

Author Comment

by:gokyo66
ID: 18794527
When Im talking about CLASSPATH Im talking about the one that you should configure when you add a library. The backslash missing is just a typo.

Now I changed, in the CLASSPATH & SOURCE under "Library Manager" I puted
%NETBEAN%\enterprise3\apache-tomcat-5.5.17\common\lib\servlet-api.jar.

Anyway for me the CLASSPATH is where you set the path to your .class or .jar file but maybe Im wrong
0
 

Author Comment

by:gokyo66
ID: 18794924
I don't know if is correct but I open a new project I added a test class called ServletTest, under the "Project - Libraries" I added the Servlet-API.jar & now it works...

Should work like that?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18795057
>> the CLASSPATH is where you set the path to your .class or .jar file but maybe Im wrong

That's correct. Its the path to your .class files to be used, and they could be in folders or JARs - you would accordingly include them.

>> under the "Project - Libraries" I added the Servlet-API.jar

Yes, because Netbeans uses the classpath specified under Libraries. That's what I'd meant when I said that Netbeans will use its own classpath....
0
 

Author Comment

by:gokyo66
ID: 18795142
ic what you mean, but tell me at this point what kind of libraries should I add under "Tools-Library Manager" voice menu?
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18796721
Add all libraries that you need to reference in your project
0
 

Author Comment

by:gokyo66
ID: 18799402
In this case can you explain me this pls...

Under a menu "File" I choose "Open File" & not "Open Project" I open a single Servlet class, after a while the source code became plenty of red stuff telling me "package javax.servlet.* does not exist", what I naturally think is that the CLASSPATH is missing... In this case, coz is not a Project but a single file, I don't have a chance to add CLASSPATH if not using "Library Manager"... but even like this the red stuff are still there and persist after doing "Fix Import" either.

Something is not clear for me...

0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18801124
In the IDE, you need to have the servlet class in a project and then configure the project's build path with the required libraries.
0
 

Author Comment

by:gokyo66
ID: 18801632
oh ic...

that means that for every class I have to open a project or just for Servlet class... & BTW why I have to open a project for a Servlet, is a requiremnt of NetBeans? Last question I promise...
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 50 total points
ID: 18802710
You can just create a Web project and put as many servlets as you want in it. Servlets are web components, and will be deployed along with a web app (in a .war file) that has a web.xml, etc - so you need to have a web app project in Netbeans to simplify all that development and grouping for you.
0
 

Author Comment

by:gokyo66
ID: 18802749
Well thank you very much for your support has been appriciate.

Cheers
Roberto
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18804586
:-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb stateless example 2 62
hashmap order 17 59
Coding for the first time 9 96
PythonWin Visual Debugger not updating variables during code step through 2 32
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question