• Post Reply Bookmark Topic Watch Topic
  • New Topic

j2ee

 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this thread is a spin off from Amanda Weber's topic installing J2EE, so I could get notified thru my e-mail.
==================================================
i have seen Chris' referal to Simon Brown's article on J2EE. does those settings:
set JAVA_HOME=c:\j2sdk1.4.1
set J2EE_HOME=c:\j2sdkee1.3.1
would enable me to import J2EE classes? or should i also set:
set J2EE_CLASSPATH=C:\j2sdkee1.3.1\bin
sun's direction says:
. Editing the user configuration script is a required step during the installation procedure. the user configuration script on Windows is in bin\userconfig.bat.
and that userconfig.bat file contains settings for JAVA_HOME and J2EE_CLASSPATH only & no setting for J2EE_HOME.
also in CattleDrive, it says to set the CLASSPATH to J2EE.jar. setting the CLASPATH would disable the compiler to see classes in the current working directory right?
i mean, when i compile a file with no package, the class file is saved in the same directory and if that file extends or use in composition another class whose class file is also in the same diretory, there is no need to import. setting CLASSPATH disables this somehow. it only looks for classes in the directory where packages are stored.
so what should i really do?
thanks in advance...
 
Manjunath Subramanian
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if i understood your question right.
What i normally do is set the classpath to j2ee.jar in the enviornment variables settings and compile the files using,
javac -classpath .;%classpath%;C:/Other Classes; *.java
This would help in compiling all the source files from my current folder.
Hope this helps,
Manjunath
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The two environment variables JAVA_HOME and J2EE_HOME are for defining the root directories of your j2sdk and j2ee installations.
At the moment you have a PATH and a CLASSPATH already set up.
echo %PATH% and echo %CLASSPATH% shows them.
CLASSPATH should probably include . meaning your current working directory.
You should already have the j2sdk1.4.1_01\bin in your PATH.
To use the J2EE commands (e.g j2ee -verbose) you need to prefix %J2EE_HOME%\bin to your existing PATH.
set PATH=%J2EE_HOME%\bin;%PATH% does that.
You should also have installed Ant and defined ANT_HOME to be the root directory of the Ant installation.
Again modify the PATH:
set PATH=%ANT_HOME%\bin;%PATH%
The ant command should now work.
Regarding CLASSPATH you can (but the tutorial does not list it in the list of environment variables) add the j2ee.jar file to it:
set CLASSPATH=%J2EE_HOME%\lib\j2ee.jar;%CLASSPATH%
Using the above you will not need to modify the %J2EE_HOME%\bin\userconfig.bat file.
Packages:
When using packages, the CLASSPATH setting should include the directories containing the directories representing the first elements of the packages.
Suppose you have a directory C:\myhome\packages and in that directory you have the directory
com\benjoes\marsLander
Do something like:
set BENJOES_PACKAGES=C:\myhome\packages
set CLASSPATH=%BENJOES_PACKAGES%;%CLASSPATH%
Now in your java program you can use:

And from another file you can do:

The fact that %BENJOES_PACKAGES% is prefixed to your class path enables the classes in %BENJOES_PACKAGES%\com\benjoes\marslander to be found.
Notice that you have to do
java com.benjoes.marslander.MarsLanderModule to invoke the main method of the MarsLanderModule class.
Also the CLASSPATH is scanned in order front to back. The first class found wins, so make sure the order of your CLASSPATH (and PATH in case of programs and commands) is correct.
Hope that helps a little.
-Barry
[ January 02, 2003: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To understand CLASSPATH and get a much better explanation that mine, take a look at Thinking in Java 3rd Edition freely downloadable from Bruce Eckel's site.
 
Benjoe Reyes
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Barry for the input... i think i got it, it seem s to me that my set classpath line would build up right? and the set path could be done separately per path needed,unlike the classpath?
but i don't have Ant and doesn't know anything about it. do i need it at my level or i can do w/o it for a while?
[ January 03, 2003: Message edited by: Benjoe Reyes ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!