Wednesday, September 7, 2016

How To Install Tomcat In OS X

Tomcat Installation

Download the latest binary distribution of tomcat, in my case apache-tomcat-8.0.37.tar.gz, from apache

Extract the file from the tar archive and move the tomcat folder to /opt:

cd Downloads/
tar -xvf apache-tomcat-8.0.36.tar.gz 
mv apache-tomcat-8.0.36 /opt

Set CATALINA_HOME and PATH Environment Variables

$ nano ~/.bash_profile
(~/.bash_profile)

# Set Catalina Home
export CATALINA_HOME=/opt/apache-tomcat-8.0.36
# Export Catalina/bin to path
export PATH=$PATH:$CATALINA_HOME/bin

Common Tomcat Commands

To start tomcat, open a shell Terminal window in any directory and issue the command:

$ startup.sh

Test Tomcat installation by pointing your browser to: http://localhost:8080

To stop tomcat, type on the shell:

$ shutdown.sh

To read the log file:

cd /opt/apache-tomcat-8.0.36/logs
tail -f catalina.out

Manager Web Application

The Manager App is an application that comes with Tomcat and allows you to start, stop, reload and undeploy web applications installed in Tomcat

To allow the access to the Manager App add a manager user to the tomcat users configuration file.

Edit the tomcat-users.xml file:

$ nano /opt/apache-tomcat-8.0.36/conf/tomcat-users.xml

add the following two lines:

<tomcat-users>
...
<role rolename="manager-gui"/>
<user username="manager" password="password" roles="manager-gui"/>
</tomcat-users>

Friday, September 2, 2016

How To Install Maven In OS X

Maven Installation


Download Apache Maven from its website: http://maven.apache.org/bindownload.cgi
Copy the archive file to /opt directory and extract it:
$ cd Downloads
$ cp apache-maven-3.3.9-bin.tar.gz /opt
$ cd /opt
$ tar -xvf apache-maven-3.3.9-bin.tar.gz 

Set M2_HOME and PATH Environment Variables


$ nano ~/.bash_profile
(~/.bash_profile)

# Set Maven Home
export M2_HOME=/opt/apache-maven-3.3.9

# Export Maven bin to path
export PATH=$PATH:$M2_HOME/bin
You can check the PATH by issuing the commands:
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/apache-ant-1.9.7/bin:/opt/apache-maven-3.3.9/bin
You can check maven installation by issuing the command:
$ mvn -version
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /opt/apache-maven-3.3.9
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"

How to Install Ant in OS X

Ant Installation

Download Apache Ant from its website: http://ant.apache.org/bindownload.cgi

Copy the archive file to /opt directory and extract it:

cd Downloads
cp apache-ant-1.9.7-bin.tar.gz /opt
cd /opt
tar -xvf apache-ant-1.9.7-bin.tar.gz

Friday, August 19, 2016

How To Install JBoss AS 7 in Ubuntu

This guide is aimed at developers wanting to set up their development environment.

First, you should have a JDK-7 installed on your machine. If you have a JDK-8, JBoss AS 7.x will not start.
Then, in your .profile file, set the JAVA_HOME environment variable pointing to java installation.

To download JBoss 7 application server issue the following command on terminal:

wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz

Untar the archive:

tar -xvf jboss-as-7.1.1.Final.tar.gz 

Copy the directory to /opt/redhat-jboss-as-7:

sudo cp -r jboss-as-7.1.1.Final /opt/redhat-jboss-as-7

You don't want the jboss process to run as root on your machine, so you need to change the owner and owner group of jboss. Assume you are logged as the user max, to set the owner user and owner group on the jboss directory, issue the following command:

sudo chown -R max:max /opt/redhat-jboss-as-7

To start JBoss type on the shell:

max@ubuntu-host:/opt/redhat-jboss-as-7/bin$ ./standalone.sh

Monday, August 15, 2016

How To Install Tomcat 8 in Ubuntu

Install Oracle's JDK

Install Java, see here

Set the JAVA_HOME, CATALINA_HOME and PATH environment variables

The JAVA_HOME variable is used by Java Servers such as Tomcat and JBoss.

The CATALINA_HOME variable is required by when running Tomcat from command line to locate the files stored in $CATALINA_HOME/conf and $CATALINA_HOME/logs directories.

To set user environment variables edit the ~/.profile:

max@ubuntu-host:~$ nano ~.profile

Append the following lines to the ~.profile file:

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export CATALINA_HOME=/opt/apache-tomcat-8.0.38
export PATH=$PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin

Thursday, August 11, 2016

How to Install Java In Ubuntu

Which Version of Java to Use?

  • JDK 7 supports:
    • eclipse version 4.4 - 4.5
    • JBoss AS 7 with Java EE 6 features
    • Tomcat 7-8 with WebSockets
  • JDK 8 (LTS) supports:
    • eclipse from eclipse Neon (4.6) to eclipse 2020-06 (4.16)
    • WildFly from 8 to 13 with Java EE 7 features
    • WildFly from 14 to 25 with Jakarta EE 8 features
    • Tomcat 9 with Java EE 8 features
    • Eclipse GlassFish 5.1.0 with Java EE 8 and Jakarta EE 8
    • Eclipse Glassfish 6.0.0 with Jakarta EE 9
  • JDK 11 (LTS) supports:
    • eclipse IDE from Eclipse 4.17 (2020-09) to Eclipse 4.24 (2022-06)
    • Eclipse Glassfish 6.1 with Jakarta EE 9.1
  • JDK 17 (LTS) supports:
    • eclipse IDE from eclipse 4.25 (2022-09) to eclipse 4.28 (2023-06)
    • Eclipse Glassfish 6.2.2 with Jakarta EE 9.1

By march 2019, Java SE 8 will go through the End of Public Updates process, because it is a legacy release.

The java programming language is an open source project. The OpenJDK community works for a free open-source implementation of the Java SE standard and Oracle contribute to the OpenJDK project. Beginning with Java SE 11 (September 2018, LTS), Oracle provide free releases and commercially supported releases for use with Oracle products: OpenJDK (free) and Oracle JDK (commercial) builds from Oracle. The OpenJDK project is the basis for both OpenJDK and Oracle JDK builds: applications will run interchangeably on Oracle JDK-11 and OpenJDK JDK-11.

Monday, July 25, 2016

jQuery and forms

Selecting form controls with jQuery selectors

jQuery selector working with forms are not always the fastest option to select elements: when you use them remember to reduce the number of elements jQuery needs to look through. Orthewise, use common CSS selectors

Example of use of jQuery selectors for forms

/* to start, select all form descendants,
   then, use the filter() method on the initial selection */
var $formDescs = $('form *');

/* :input selects all button, input, select and textarea */
var $inputs = $formDescs.filter(':input');
  
/* :text selects input type="text" and input */  
var $text = $inputs.filter(':text'); 

/* :password selects input type="password" */
var $password = $inputs.filter(':password');   

/* :button selects button and input type='button' */
var $button = $inputs.filter(":button");  

/* :checked selects all checked inputs from group of radio and check inputs */
var checked = $inputs.filter(":checked");

/* :selected selects all selected options from drop boxes */
var selected = $inputs.filter(":selected"); 

Wednesday, July 13, 2016

jQuery Effects

Effects

jQuery effects includes transitions and movements

  • show and hide elements
  • animate elements with fade in and fade out
  • animate elements with slide up and slide down
jQuery method method meaning
Basic Effects $('selector').show() set the display CSS property to element's default value
$('selector').hide() set the display CSS property to none
$('selector').toggle() toggle between showing and hiding elements
Fading Effects $('selector').fadeOut() make element disappear by changing both opacity and display CSS properties
$('selector').fadeIn() make element appear by changing both opacity and display CSS properties
$('selector').fadeTo() change the opacity CSS property
$('selector').fadeToggle() hide or show the element
Sliding Effects $('selector').slideUp() hide the element with sliding movement
$('selector').slideDown() show the element with sliding movement
$('selector').slideToggle() hide or show the element
Custom Effects $('selector').delay() delay the execution of the following method
$('selector').stop() stop the animation
$('selector').animate() create a custom animation

Monday, July 11, 2016

jQuery Traversing and Filtering

DOM Traversing

The jQuery methods for traversing the DOM allow to access other element nodes relative to the initial selection.

jQuery methodmethod meaning
$('selector').find('selector2') all the elements in the current selection matching selector2
$('selector').closest('selector2') the nearest ancestral element matching selector2
$('selector').parent() the direct parent element of current selection
$('selector').parents() all the parents of current selection
$('selector').children() all the children of current selection
$('selector').next() next sibling of current element
$('selector').prev() previous sibling of current element

Monday, July 4, 2016

jQuery and events

Checking When a Page is Ready For Your Code

The ready() method executes its function argument when the page is ready to work

$(document).ready(function(){
  // function body
});
  • Behind the scenes, the ready() method add a listener for DOMContentLoaded events or for load events (in browsers that do not support HTML5 events a load event is fired instead)

There is a shorthand code for the ready() method:

$(function(){
  // function body
});

If you do not wish to use jQuery but still run your code when the page is ready to work, place your script before the body closing tag.

Friday, July 1, 2016

Scripting DOM and CSS with jQuery

Getting and Setting Element Content

The .html() and .text() methods retrive and update the content of elements.

How To Retrieve Element Content

jQuery methodmethod meaning
html = $('selector').html() get the HTML content of the first element in the jQuery selection
text = $('selector').text() get the textual content from every element in the jQuery selection and any descendant