Personal notes on Java
For other technologies like HTML, CSS, .NET, PHP, etc. check my other blog

Install Java Platform Standard Edition (needed to to build and deploy source code); Download the current JDK update that does not include any other software, such as NetBeans IDE or the Java EE SDK;



Install Java EE 6 Software Development Kit To obtain the GlassFish Server, you must install the Java EE 6 Software Development Kit (SDK), which you can download here.
NOTE: Make sure you download the Java EE 6 SDK, not the Java EE 6 Web Profile SDK.


Install NetBeans IDE: the official free, open-source IDE for developing Java applications, including enterprise applications. You can build, package, deploy, and run the applications from within NetBeans IDE. You can download it here.
NOTE: Make sure that you download the Java EE bundle AND do not install the version of GlassFish Server that comes with NetBeans IDE.


Add GlassFish Server as a Server in NetBeans IDE
  • From Netbeans IDE
  • Servers;
  • Click Add Server.
  • Under Choose Server, select GlassFish Server 3.x and click Next.
  • Under Server Location, browse to the location of your GlassFish Server installation and click Next.
  • Under Domain Location, select Register Local Domain.
  • Click Finish.
Set the class path environment variable of your system
NOTE: you may need to open a new console for the new variables to take effect.
To edit/update environment variables in Windows Xp go to:

In order to use java.exe (to run java apps) and javac.exe (java compiler) from the command line, you need to add the the folder where this files reside (ex. C:\Program Files\Java\jdk1.7.0_01\bin ) to the PATH environment variable.
Select the "Path" variable on the System Variables and click "edit" to add this folder.
Why? The PATH environment variable on your computer designates which directories the computer searches when looking for applications, such as the applications that enable you to compile and run your Java applications (called javac.exe and java.exe).


NOTE: The DOS "SET" command can be used to check environment variables quickly on the console but not to set environment variables since the "set" command used in the console is only temporary and only works for the active console, once you close it all variables are reseted.
 DOS "set" command tips:
  • print all variables: C:\ set
  • print all variables that begging with "J":
    C:\ set J
    (alternatively you can print a specific variable with the "echo" command:
    C:\ echo %JAVA_HOME%)
  • Set a variable (temporary):
    C:\> set JAVA_HOME=C:\jdk1.5
  • Append a value to a variable (values are separated by ";"):
    C:\ set PATH=%PATH%;%JAVA_HOME%\bin



A compilation of variables you may want to set:
JDK variables ( to use commands in the console like: java, javac, jar, etc.)

Verify JDK:
C:\> java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)

If you don't get the previous result you need to set this variables:
  • Set the JAVA_HOME environment variable to the root location of the JDK installation directory
    JAVA_HOME=C:\jdk1.5
    Other locations where you may find it: C:\Program Files\Java\jdk1.7.0_01
  • Set the PATH environment variable to include the JDK bin directory. The PATH variable tells the operating system where to find the java interpreter and the javac compiler.
    Append ";%JAVA_HOME%\bin" to the already existing "PATH" variable

Ant Variables:
Verify ant
By default ant uses a "build.xml" script file, so if one does not exist in the current folder you get a message like below meaning that ant is working:
C:\ ant
Buildfile: build.xml does not exist!
Build failed
  • If you didn't get the previous message:
    append ;"C:\glassfish3\ant\bin" to your "PATH" variable;

JavaDB (Apache Derby) Variables [2]:
  • set  DERBY_INSTALL variable to your JavaDB installation directory ex.:
    C:\Program Files\Java\jdk1.7.0_01\db
    (other places where you may find it:  C:\Apache\db-derby-10.8.2.2-bin)
  • To use Derby in its embedded mode set your CLASSPATH to  .;%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar
    in order to include the jar files listed below:
        - derby.jar: contains the Derby engine and the Derby Embedded JDBC driver;
        - derbytools.jar: optional, provides tols like the ij tool (a command line client to query the DB);
    Launch the sysinfo tool to test the variables:
        C:\ java org.apache.derby.tools.sysinfo
        (will output information of the system like java version; OS; Derby Version; Locales; etc.)
    Launch the ij tool:
        C:\ java org.apache.derby.tools.ij
        ij version 10.8
        ij> exit;
    (the tool runs and presents the "ij>" command line. Type "exit;" to quit the tool.)
  • Derby provides multiple batch files that make using tools easier, the ij.bat file for example automatically launches the ij tool, these batch files are available on the derby "bin" directory.
    So append ";%DERBY_INSTALL%\bin" to your PATH variable.
    Now you can run the previous sysinfo tool by just typing:
        C:\ sysinfo
    Or the ij tool with:
        C:\ ij



Configure debugging options:
http://download.oracle.com/javaee/6/tutorial/doc/bnadl.html

Resources:
[1] - The Java EE 6 Tutorial  - Required Software

Sem comentários:

Enviar um comentário