muskad202
asked on
directory structure in Tomcat
hi !!
(1) i read somewhere that, if the directory structure within C:\tomcat\webapps is the correct format, then , u don't need to use ANT to deploy the appliaction, u just copy the .java files in the correct location, and when u start tomcat, it will compile the code, etc. can someone show me the proper directory structure for this ?
(2) also, the webapp uses some java libraries that need to be in the classpath. is there any way to have that path added to the classpath automatically? i don';t want to tell the client that he has to set the classpath manually.
(3) one last Q, .. i want to use a .properties file from my webapp .. where should i physically place the file? i tried placing it in the same folder as the .class files, but it didn't work .. it only worked when i placed it in c:\tomcat\bin\ but i don't want to do that, becoz, what i'm trying to do is, give the client a folder, and all that is required is to place it in c:\tomcat\webapps, i don't want to tell him to manually copy a file into c:\tomcat\bin
thanks :)
(1) i read somewhere that, if the directory structure within C:\tomcat\webapps is the correct format, then , u don't need to use ANT to deploy the appliaction, u just copy the .java files in the correct location, and when u start tomcat, it will compile the code, etc. can someone show me the proper directory structure for this ?
(2) also, the webapp uses some java libraries that need to be in the classpath. is there any way to have that path added to the classpath automatically? i don';t want to tell the client that he has to set the classpath manually.
(3) one last Q, .. i want to use a .properties file from my webapp .. where should i physically place the file? i tried placing it in the same folder as the .class files, but it didn't work .. it only worked when i placed it in c:\tomcat\bin\ but i don't want to do that, becoz, what i'm trying to do is, give the client a folder, and all that is required is to place it in c:\tomcat\webapps, i don't want to tell him to manually copy a file into c:\tomcat\bin
thanks :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> that will make it available for all webapps deployed on thatt server.
But be warned, it could cause problems if you (for example) have a webapp that uses a different version of xerces or something...
But be warned, it could cause problems if you (for example) have a webapp that uses a different version of xerces or something...
ASKER
hi !!
thanks for replying :)
one thing though .. i need to load the properties from a static constructor of a class .. but the this.getClass() requires an object .. how do i get around that ?
i tried something like
properties.load(new FileInputStream("../global .propertie s"));
(the ../ is because the java file that loads the properties is within a package .. its physical location is web-inf\package\file)
but it din't work :(
thanks :)
thanks for replying :)
one thing though .. i need to load the properties from a static constructor of a class .. but the this.getClass() requires an object .. how do i get around that ?
i tried something like
properties.load(new FileInputStream("../global
(the ../ is because the java file that loads the properties is within a package .. its physical location is web-inf\package\file)
but it din't work :(
thanks :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> i need to load the properties from a static constructor of a class
what's a static constructor?
what's a static constructor?
> what's a static constructor?
public class SomeClass
{
static
{
// some static initialisation stuff here
}
}
public class SomeClass
{
static
{
// some static initialisation stuff here
}
}
ASKER
e.g.
--------------
// Hullo.java
public class Hullo
{
static
{
System.out.println("Hello World without main!!!!");
}
}
--------------
if u compile and then run, then, it will complain that there is no main method. but, before that, it will print "Hullo world", becoz the class was loaded into memory
--------------
// Hullo.java
public class Hullo
{
static
{
System.out.println("Hello World without main!!!!");
}
}
--------------
if u compile and then run, then, it will complain that there is no main method. but, before that, it will print "Hullo world", becoz the class was loaded into memory
So, for my example, I would do:
public class SomeClass
{
static Properties properties ;
static
{
properties.load( SomeClass.class.getResourc eAsStream( "/global.properties" ) ) ;
}
}
public class SomeClass
{
static Properties properties ;
static
{
properties.load( SomeClass.class.getResourc
}
}
> (the ../ is because the java file that loads the properties is within a package .. its physical location is web-inf\package\file)
The "/" at the front of "/global.properties" tells it to look in the root of the classpath, so you don't need the ".." with getResourceAsStream()
The "/" at the front of "/global.properties" tells it to look in the root of the classpath, so you don't need the ".." with getResourceAsStream()
ASKER
>properties.load( YourClass.class.getResourc eAsStream( "/global.properties" ) ) ;
>Just replace "YourClass" with the class that you are doing the loading from :-)
--------
works perfectly ... thanks :)
>Just replace "YourClass" with the class that you are doing the loading from :-)
--------
works perfectly ... thanks :)
:-) Cool :-)
Good luck with it :-)
Tim
Good luck with it :-)
Tim
tomcat\common\lib
that will make it available for all webapps deployed on thatt server.