Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar files

 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a jar files which i store in web-inf/lib in my web application folder. if i want to call a class in the jar files from my servlet, how am i going to do that?
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You just import the class into your code and instantiate the objects as usual.
 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i try to do that but i still got error which says the package does not exist. and one more question is can u tell me about this error

.....cannot resolve symbol
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suka Hati,
That error is raised by compiler when it doesn't find proper class which you use because you dont give the proper classpath of the library.

May I know what class you used?

As you said that you build a web application, i think it is the best way to check again the directory structure of your web application.
All the extended library, you use, is placed on <web-app>\WEB-INF\lib

Hope this help
Correct me if I am wrong
thanks
daniel
 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi...

i do put my .jar files in folder tomcat/webapps/speech/WEB-INF/lib/**.jar

i just need to import it as usual...(like below)

import ***.*;

and call the class that i need in those .jar files....(like below)

Try try=new Try();

is it true, or there's other way to do it?
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Suka Hati,
I think you are right about that.
And you can use class on that library and it should run well...
Let me know what's error you have when you run that application...

thanks
daniel
 
Suka Hati
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the error that i got is:

package *** does not exist

should i add the path of the package in the CLASSPATH....actually i have done it but there's no different
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic