wood burning stoves 2.0*
The moose likes Websphere and the fly likes adding jar files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "adding jar files" Watch "adding jar files" New topic
Author

adding jar files

Harold Luka
Greenhorn

Joined: Jan 15, 2004
Posts: 5
can someone tell me how to add a jar file to my project in websphere?
essentially, i got the jakarta apache fileupload component and i want to install it on my websphere. I tried right clicking my project, java build path, then add the jar file there but apparently that's wrong as when i use the class in my code, in the tasks list it says xxx(class) cannot be resolved or is not a type.
Thanks!
[ January 15, 2004: Message edited by: Harold Luka ]
chandubcs
Ranch Hand

Joined: Jun 03, 2001
Posts: 47
You also need to import that .jar file in Project Libraries.
Harold Luka
Greenhorn

Joined: Jan 15, 2004
Posts: 5
can you give me a little more details?
so right click my project's libraries, import, zip file, then my jar file?
just tried that...still said xxx(class) cannot be resolved or is not a type...
chandubcs
Ranch Hand

Joined: Jun 03, 2001
Posts: 47
1. select Project, right click to view its properties, select 'Java Build-Path', click 'Libraries' tab at top, click 'Add External Jars' and select the appropriate library from your local disk then click on OK and save the project.
2. In the Project list, select 'Libraries', right click and select 'Import', select 'File System' and select the same library from your local system which you did earlier in step 1 above, check the appropriate library and in the 'into folder' text box click on your project-name/ejbModule for EJB project and project-name/WebContent, then click on OK and save the project.
Harold Luka
Greenhorn

Joined: Jan 15, 2004
Posts: 5
that doesn't seem to work for me. File system needs a directory but i got a jar file. I tried the zip file option too, but it doesn't seem to work too. Am I missing something?
chandubcs
Ranch Hand

Joined: Jun 03, 2001
Posts: 47
for #2, Right Click on Libraries -> Import -> select File System -> In the from directory, use browse button to locate your .jar file in your local disk, you will get the directory in the left panel with + symbol and the name of directory, after clicking on that directory in the right panel you can see list of files, select your appropriate .jar file from right panel by marking the check box. Then for 'into folder' box, click on browse, select your project-name and under your project you can see 'Web-Content' of web projects and 'EJB-module' of EJB projects, select them and click OK to save.
chandubcs
Ranch Hand

Joined: Jun 03, 2001
Posts: 47
Try this if the above doesn't work..........
In Server perspective, under 'Server Configuration' window at the bottom, double click on the server you are using. In the properties window at right side, click on Environment tab (3rd tab), and under 'ws.ext.dirs' click on 'Add External Jars', select .jar from local disk, then save the server and restart it.
If the above optios doesn't work, use below 2 options:
1. Go to Window -> Preferences -> Java -> Classpath Variables -> NEW button -> Give Name/path -> OK
For JDBC drivers:
2. Go to Window -> Preferences -> JDBC Drivers -> Add Jar -> OK
Tony Chen
Ranch Hand

Joined: Jan 29, 2001
Posts: 286
why not simply copy the jar file into \workspace\your_project\Web Content\WEB-INF\lib


SCJP Java 2 - IBM Certified Enterprise Developer - WebSphere V4.0 & V5.0 - IBM Certified System Administrator - WebSphere Network Deployment V6.0 - Canadian Securities Course (CSC) Certification
Kim Wall
Greenhorn

Joined: Sep 06, 2001
Posts: 2
Tony is right, simply adding the jar file to the \workspace\your_project\Web Content\WEB-INF\lib directory will not only resolve your runtime issues but will take care of the Java Build Path for compile time issues as well.
Please keep in mind that if you add the jar file to the ws.ext.dirs directory in your server configuration, you're making the assumption that that jar file will also be available on the server to which you deploy your code in your production environment. If it is not there, you'll see the same error as you are currently seeing.
One other thing to consider, if you have multiple web projects contained within your Enterprise Application Project that all need to use that particular jar file. You may wish to put that jar file at the root of the Enterprise Application Project and then add it as a Java JAR Dependency for each of the web projects. To do this, ensure that the web project is associated with the Enterprise Application project and then right click on the web project and choose 'Properties'. Then, choose 'Java JAR Dependencies' and check the appropriate jar(s) from the list.
Good luck!
 
 
subject: adding jar files