You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by polock <jo...@yahoo.com> on 2008/02/14 18:10:36 UTC

using a class from jar file

Dear all, 
I just put a jar file in my webapps folder and now I would like to write
some java files with classes that are available within jar file that will be
also part of a web applications.
Where should I place this new java files?
Shouldf they be compiled?
Thank you in advance
PS. Also I would appreciate a reffernce to some documents where this is
explained!
-- 
View this message in context: http://www.nabble.com/using-a-class-from-jar-file-tp15481864p15481864.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: using a class from jar file

Posted by polock <jo...@yahoo.com>.
The problem is that I cannot find classes in the WEB_INF\classes directory
that I want to extend with my new class. I only have found some .properties
file.
I was trying to import a war file in eclipse and I coud not find an option
that will make it possible. Can these properties files be of any help?
Thank you

David Smith-2 wrote:
> 
> The required jar files will have to be made available to the java 
> compiler.  They can be made available either by pulling them from your 
> war file or by downloading them from the sites that host them.  
> Personally I would have an IDE (NetBean and Eclipse are both good, open 
> source choices) or build tool (Maven and Ant are both excellent open 
> source tools) handle the dirty work of compiling classes.
> 
> --David
> 
> polock wrote:
>> I made a mistake I wanted instead of war file I wrote a jar file. So the
>> web
>> application has been already created. My question is if I have to compile
>> a
>> java class that extends one of the classes included in a jar file. Do I
>> have
>> to extract from war file necessary libraries need for the compilation of
>> my
>> file or there is a more elegant way to handle this?
>>
>> Christopher Schultz-2 wrote:
>>   
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> To whom it may concern,
>>>
>>> polock wrote:
>>> | I just put a jar file in my webapps folder
>>>
>>> That's not the place to put it.
>>>
>>> | now I would like to write
>>> | some java files with classes that are available within jar file that
>>> will be
>>> | also part of a web application.
>>>
>>> | Where should I place this new java files?
>>>
>>> You need to create a web application, then. Find an online tutorial or a
>>> book, and you'll see that a web application needs to have a directory
>>> structure like this:
>>>
>>> webapps/yourwebapp
>>> webapps/yourwebapp/WEB-INF
>>> webapps/yourwebapp/WEB-INF/lib
>>> webapps/yourwebapp/WEB-INF/classes
>>>
>>> Your JAR files go under the "lib" directory and your compiled Java
>>> classes go under the "classes" directory (of course, in
>>> package-appropriate subdirectories). You should really also have a
>>> web.xml file in WEB-INF.
>>>
>>> Note that the Java source files are irrelevant to a web application:
>>> they need not be included.
>>>
>>> | Should they be compiled?
>>>
>>> Yes, and they should be installed under the "classes" directory as
>>> indicated above.
>>>
>>> | Also I would appreciate a reffernce to some documents where this is
>>> | explained!
>>>
>>> GIYF (Google is your friend): try searching the web for this
>>> information, as it is plentiful. Ignore anything that references "Apache
>>> JServ" which is an outdated servlet container that has been out of use
>>> for quite a long time (yet the documentation seems to survive on the web
>>> for some reason).
>>>
>>> - -chris
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.8 (MingW32)
>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>>
>>> iEYEARECAAYFAke0eJ4ACgkQ9CaO5/Lv0PAV3gCeJDvpuaDehMXx/3mFreIOZWqb
>>> 5i8AoLgOeqI4AzX8l9Wvbgt9gCxy6ZBX
>>> =Gzpw
>>> -----END PGP SIGNATURE-----
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>     
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/using-a-class-from-jar-file-tp15481864p15562362.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: using a class from jar file

Posted by David Smith <dn...@cornell.edu>.
The required jar files will have to be made available to the java 
compiler.  They can be made available either by pulling them from your 
war file or by downloading them from the sites that host them.  
Personally I would have an IDE (NetBean and Eclipse are both good, open 
source choices) or build tool (Maven and Ant are both excellent open 
source tools) handle the dirty work of compiling classes.

--David

polock wrote:
> I made a mistake I wanted instead of war file I wrote a jar file. So the web
> application has been already created. My question is if I have to compile a
> java class that extends one of the classes included in a jar file. Do I have
> to extract from war file necessary libraries need for the compilation of my
> file or there is a more elegant way to handle this?
>
> Christopher Schultz-2 wrote:
>   
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> To whom it may concern,
>>
>> polock wrote:
>> | I just put a jar file in my webapps folder
>>
>> That's not the place to put it.
>>
>> | now I would like to write
>> | some java files with classes that are available within jar file that
>> will be
>> | also part of a web application.
>>
>> | Where should I place this new java files?
>>
>> You need to create a web application, then. Find an online tutorial or a
>> book, and you'll see that a web application needs to have a directory
>> structure like this:
>>
>> webapps/yourwebapp
>> webapps/yourwebapp/WEB-INF
>> webapps/yourwebapp/WEB-INF/lib
>> webapps/yourwebapp/WEB-INF/classes
>>
>> Your JAR files go under the "lib" directory and your compiled Java
>> classes go under the "classes" directory (of course, in
>> package-appropriate subdirectories). You should really also have a
>> web.xml file in WEB-INF.
>>
>> Note that the Java source files are irrelevant to a web application:
>> they need not be included.
>>
>> | Should they be compiled?
>>
>> Yes, and they should be installed under the "classes" directory as
>> indicated above.
>>
>> | Also I would appreciate a reffernce to some documents where this is
>> | explained!
>>
>> GIYF (Google is your friend): try searching the web for this
>> information, as it is plentiful. Ignore anything that references "Apache
>> JServ" which is an outdated servlet container that has been out of use
>> for quite a long time (yet the documentation seems to survive on the web
>> for some reason).
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.8 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>>
>> iEYEARECAAYFAke0eJ4ACgkQ9CaO5/Lv0PAV3gCeJDvpuaDehMXx/3mFreIOZWqb
>> 5i8AoLgOeqI4AzX8l9Wvbgt9gCxy6ZBX
>> =Gzpw
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: using a class from jar file

Posted by polock <jo...@yahoo.com>.
I made a mistake I wanted instead of war file I wrote a jar file. So the web
application has been already created. My question is if I have to compile a
java class that extends one of the classes included in a jar file. Do I have
to extract from war file necessary libraries need for the compilation of my
file or there is a more elegant way to handle this?

Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> To whom it may concern,
> 
> polock wrote:
> | I just put a jar file in my webapps folder
> 
> That's not the place to put it.
> 
> | now I would like to write
> | some java files with classes that are available within jar file that
> will be
> | also part of a web application.
> 
> | Where should I place this new java files?
> 
> You need to create a web application, then. Find an online tutorial or a
> book, and you'll see that a web application needs to have a directory
> structure like this:
> 
> webapps/yourwebapp
> webapps/yourwebapp/WEB-INF
> webapps/yourwebapp/WEB-INF/lib
> webapps/yourwebapp/WEB-INF/classes
> 
> Your JAR files go under the "lib" directory and your compiled Java
> classes go under the "classes" directory (of course, in
> package-appropriate subdirectories). You should really also have a
> web.xml file in WEB-INF.
> 
> Note that the Java source files are irrelevant to a web application:
> they need not be included.
> 
> | Should they be compiled?
> 
> Yes, and they should be installed under the "classes" directory as
> indicated above.
> 
> | Also I would appreciate a reffernce to some documents where this is
> | explained!
> 
> GIYF (Google is your friend): try searching the web for this
> information, as it is plentiful. Ignore anything that references "Apache
> JServ" which is an outdated servlet container that has been out of use
> for quite a long time (yet the documentation seems to survive on the web
> for some reason).
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.8 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAke0eJ4ACgkQ9CaO5/Lv0PAV3gCeJDvpuaDehMXx/3mFreIOZWqb
> 5i8AoLgOeqI4AzX8l9Wvbgt9gCxy6ZBX
> =Gzpw
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/using-a-class-from-jar-file-tp15481864p15547050.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: using a class from jar file

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To whom it may concern,

polock wrote:
| I just put a jar file in my webapps folder

That's not the place to put it.

| now I would like to write
| some java files with classes that are available within jar file that
will be
| also part of a web application.

| Where should I place this new java files?

You need to create a web application, then. Find an online tutorial or a
book, and you'll see that a web application needs to have a directory
structure like this:

webapps/yourwebapp
webapps/yourwebapp/WEB-INF
webapps/yourwebapp/WEB-INF/lib
webapps/yourwebapp/WEB-INF/classes

Your JAR files go under the "lib" directory and your compiled Java
classes go under the "classes" directory (of course, in
package-appropriate subdirectories). You should really also have a
web.xml file in WEB-INF.

Note that the Java source files are irrelevant to a web application:
they need not be included.

| Should they be compiled?

Yes, and they should be installed under the "classes" directory as
indicated above.

| Also I would appreciate a reffernce to some documents where this is
| explained!

GIYF (Google is your friend): try searching the web for this
information, as it is plentiful. Ignore anything that references "Apache
JServ" which is an outdated servlet container that has been out of use
for quite a long time (yet the documentation seems to survive on the web
for some reason).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAke0eJ4ACgkQ9CaO5/Lv0PAV3gCeJDvpuaDehMXx/3mFreIOZWqb
5i8AoLgOeqI4AzX8l9Wvbgt9gCxy6ZBX
=Gzpw
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org