home / infca / java (navigation links) Excusi'm que no m'aixequi ...

EJB | MDB | Singleton LAMP | GUI | Links | End

Java and me


Intro CLASSPATH RedBooks


Amunt! Top Amunt!
Darrer intent - gracies, Esteve !
  1. download and install Java JDK, Java SE 7u45 {2013/12}
    Directory of c:\Program Files\Java 20-12-13 11:23 jdk1.7.0_45 20-12-13 11:23 jre7

  2. set JAVA_HOME to JDK
    c:\> echo %JAVA_HOME% c:\Program Files\Java\jdk1.7.0_45

  3. add %JAVA_HOME%\bin to PATH
    c:\Program Files\Java> echo %PATH% ... ;c:\Program Files\Java\jdk1.7.0_45\bin; ...

  4. download and install Eclipse IDE for Java EE developers, Kepler {2013/12}
  5. start Eclipse and create a New Java Project
  6. in the src folder, drop the java file
  7. select the project name, right click on it, select Build Path and then Add External Archives. Now, navigate to the JAR files {as c:\MQ\java\lib} : com.ibm.mq.jar, com.ibm.mqjms.jar, connector.jar, dhbcore.jar, fscontext.jar, jms.jar, jta.jar and providerutil.jar
  8. click F5 to refresh Eclipse
  9. mr Saper says "have ALL the jar files from the MQ Install path/java/lib on your classpath"

Sun says : (Abr/2005)
Java 2 Platform Standard Edition (J2SE) 5.0 ("Tiger") is the next major revision to the Java platform and language; it is currently slated to contain 15 component JSRs with nearly 100 other significant updates developed through the Java Community Process (JCP). Note: the external version number of this release is 5.0 and its internal version number is 1.5.0, as described at J2SE Naming and Versioning.

Download JSE 5.0 [***] Java SE, JDK o JRE.

The J2SE Development Kit (JDK) supports creating J2SE applications.
The J2SE Runtime Environment (JRE) allows end-users to run Java applications.

P4 - XP - JDK-1_5_0_02-WINDOWS-i586-p.exe install ( 14/4/2005 )
 Instala J2SE Development Kit 5.0 Update 2
 Destination : c:\Program Files\Java\JDK1.5.0_02 ( i c:\PF\Java\JRE1.5.0_02 )

 PATH :
**** T30 : E:\Program Files\Java\jdk1.5.0_02\bin; ****

 Documentació : 43,5 MB.
    Open the docs/index.html page in a browser.
    This is the front page and table of contents of the JDK documentation.

****  P4:\C:\Program Files\Java\DocuJ2SE5.0     ****
**** T30:\e:\Program Files\Java\docs\index.html ****

JAVADOC JSE 1.5, JAVADOC JEE 1.4.


Linux
 rpm -ivh j2re*.rpm

 JAVA_HOME=/usr/java/jre1.5.0_03
 export JAVA_HOME

 PATH=$JAVA_HOME/bin:$PATH
 export PATH

Now, if you want to be able to execute this version of Java interpretor or compiler from any directory on your Linux system you will have to create a few symbolic links:

  • ln -s /usr/java/j2sdk1.4.2_08/bin/java /usr/bin/java
  • ln -s /usr/java/j2sdk1.4.2_08/bin/javac /usr/bin/javac

Origin

Test your Java Runtime Environment

Run this test applet

Guapo !
CLASSPATH

The CLASSPATH is an environment variable that tells the Java compiler javac.exe where to look for class files to import or java.exe where to find class files to interpret. Així, apunta a directoris amb fitxers "nom.CLASS".

There's a variation when using JAR files, however. You must put the name of the JAR file in the classpath, not just the path where it's located. Així, també hi ha fitxers del tipus "nom.JAR"

CLASSPATH, PACKAGE and directories

If in file sebas.java I code package com.ibm.zip;, and CLASSPATH contains c:\misclases; then file sebas.java must be placed in c:\misclases\com\ibm\zip so javac or java can reach it.


Also, if we are situated at c:\sebas >, and sebas.java has package a.b.c;, then we have to place sebas.java in c:\sebas\a\b\c\ and call (from c:\sebas >) javac a\b\c\sebas.java and java a.b.c.sebas (.class).

How to set CLASSPATH

The lists are delimited by a colon ":" with Linux and Unix, and a semicolon ";" with Windows. You probably do not want to reassign their values but rather want to append them. To do this:

Linux/Unix type: export CLASSPATH=$CLASSPATH:/path/to/program Windows type: set CLASSPATH=%CLASSPATH%;C:\path\to\program

URL

java.lang.NoClassDefFoundError

¿ Cómo se carga una clase ?

Cuando se intenta ejecutar una clase, o acceder a ella durante la ejecución de un programa, la máquina virtual de Java debe cargar la clase. Para ello, necesita acceder al fichero compilado para la clase (el nombre de la clase con extensión .class, por ejemplo, MiClase.class). Para ello, busca este fichero entre las clases estándar de Java, y en todos los directorios establecidos en la variable de entorno CLASSPATH. En las últimas versiones de Java, si la variable CLASSPATH está vacía, busca también los ficheros en el directorio en el cual se está ejecutando la máquina virtual. Si no encuentra la clase, la máquina virtual lanza la excepción java.lang.NoClassDefFoundError.

url

Exemple miHola.java
c:\MyJavaDir> dir 16/12/2012 13:07 <DIR> ABC 16/12/2012 13:07 404 FER.cmd

On FER.CMD conte:

c:\MyJavaDir> type FER.CMD cd ABC javac Hola.java cd .. java ABC.Hola

Si el codi es:

c:\MyJavaDir> type .\ABC\Hola.java package ABC ; public class Hola { // main method begins execution of Java application public static void main ( String args[] ) { System.out.println( "Welcome to SAG Java Programming !" ) ; } ; // end method main } ; // end class Hola

El resultat es:

c:\MyJavaDir> java ABC.Hola Welcome to SAG Java Programming !
How to fix "java -version" (win) problems
SET PATH=$/jre/bin;%PATH%
Diferencia Applet - Aplicación
Dejando de lado las restricciones de seguridad,
  • las aplicaciones se inicializan desde main() y se despliegan en sus propias ventanas
  • los applets se inicializan y arrancan desde init() y start(), respectivamente
    Los applets ignoran el método main()

An applet is a Java program that runs on a Web page. An applet is not a stand-alone application, and it does not have a main() routine. In fact, an applet is an object rather than a class. When an applet is placed on a Web page, it is assigned a rectangular area on the page. It is the job of the applet to draw the contents of that rectangle. When the region needs to be drawn, the Web page calls a subroutine in the applet to do so.

An applet is a Java application that's designed to run in a browser window on an Internet user's computer. When an Internet user visits a Web page that contains an applet, the Java applet class is downloaded to the user's computer and run there. The applet takes over a portion of the page and, within that space, can do anything it wants.

Características
  • no Global variables
  • Case Sensitive
  • arg[0] no es el nombre del programa, sino el primer argumento de la linea de comandos despues del nombre de la clase
Class and File naming rules (from here)

A class name must start with a capital letter. The source for that class must live in a plain text file with the same name (including case), with a *.java extension. So, filename must be "Classname.java"

You cannot put more than one public class inside a *.java file.

Classes in the same package are accessible to each other, even if they are in different files. To access other classes, you must import them.

The source code must be stored in a directory with the same name as the package declared at the top of the file, including case, with the dots replaced by \ or / or whatever your platform uses for directory element separators.
A sample ?

Package names must be lower case, usually beginning com.yourwebsite to ensure global uniqueness.
It is a good idea to put every class in some package. Only experiments you plan to keep for under an hour should be without a package.

"JAVAC Name.java" produces "Name.class"

"JAVA Name" (.class is ommitted) runs the main method. The -verbose flag is quite interesting ... but talks A LOT !
Append "-trace n" to trace "Name" class. "n" is a number between 1 and 5, depending on the level of detail required. (The greater the number, the more information is gathered.)

"TIJ", chapter 5 :
This chapter covers the way that code is packaged together, and why some parts of a library are exposed while other parts are hidden. It begins by looking at the package and import keywords, which perform file-level packaging and allow you to build libraries of classes. The subject of directory paths and file names is also examined. The remainder of the chapter looks at the public, private, and protected keywords, the concept of "friendly" access, and what the different levels of access control mean when used in various contexts.
Package is Java's way of making libraries.
Import tells the compiler to bring in a package, which is a library of classes.

When you say:

 package mypackage;
at the beginning of a file, where the package statement must appear as the first noncomment in the file, you're stating that this compilation unit is part of a library named mypackage. Or, put another way, you're saying that the public class name within this compilation unit is under the umbrella of the name mypackage, and if anyone wants to use the name they must either fully specify the name or use the import keyword in combination with mypackage (using the choices given previously).
Note that the convention for Java packages is to use all lowercase letters, even for intermediate words.

It's worth keeping in mind that what the package and import keywords allow you to do, as a library designer, is to divide up the single global name space so you won't have clashing names, no matter how many people get on the Internet and start writing classes in Java.

Sample : in (1)

  • \\java\Gustavo\src\com\ibm\sebas
  • \\MisCosas\Gustavo\20040916
we have Direccion.java and Estancia.java
Direccion.java contains package com.ibm.sebas; and public class Direccion ...
Estancia.java has import com.ibm.sebas.Direccion; and uses Direccion as public void setSalida(Direccion direccion, Estancia vecina) ...

The rest of the PATH in (1) is placed in CO.BAT (and RU.BAT), as set CLASSPATH=c:\sebas\java\Gustavo\src;%CLASSPATH%;

Usual errors
Exception in thread "main" java.lang.NoSuchMethodError: main

Estamos tratando de ejecutar una clase "Prueba" a la que no le hemos añadido el método main
Dado que un applet no se invoca desde el intérprete de comandos, no tiene sentido definir el método main.

java.lang.UnsupportedClassVersionError: SimplePolygons (Unsupported major.minor version 49.0)

JDK is 1.5, while JRE is 1.4 - update JRE.

URL ?

SDK
Interface BytesMessage
From http://mindprod.com/jgloss/javacexe.html :
If you recompile A, and A depends on B (which has not changed) and B depends on C (which has changed), Javac will not recompile C, if you invoke it on A.

Under W2K WF (VMware at T30), JAVAC and JAVA are located at
"C:\Program Files\IBM\Application Developer\plugins\com.ibm.etools.server.jdk\bin\"

Under T42/XP VM it is at "c:\Program Files\IBM\Java142\bin"

javac syntax
c:\> javac -help Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -d <directory> Specify where to place generated class files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -help Print a synopsis of standard options
Java and WSAD
  • File + New + Java Project ( or "File" + "New" + "Project" )
  • Name = Folder Name
  • Drag and Drop *.java files from anywhere (but local dir)
Java links

 



Applet's

Sun tutorial : URL. Ver Links en la última página ...

On-line book : URL

On-line book exercices : URL
8.3 = dibuixar poligons ! 8.4 = array de objectes mobils !

Curs sencer : (1,6 MB) URL - also \\Java\LlibresJava\Curs1 !

AppletViewer

  • How-To
  • The AppletViewer is provided with the Java 2 SDK, Standard Edition, in the SDK's bin directory. For information about how to use the AppletViewer and other SDK tools, see Java 2 SDK Tools and Utilities. URL
  • T30 : c:\Program Files\IBM\Java14\bin\appletviewer.exe
Tips

Using Applet Viewer the Easy way (URL)

To test your applets using the applet viewer, put the following comment in your Java file:

// <applet code=AnApplet.class width=200 height=200> </applet>

Then you won't need an HTML file for your applet code. The applet viewer will parse the applet tag and display the applet. Now, you can test it your applet by typing this at the prompt:

 appletviewer AnApplet.java
Behrouz Fallahi
Maps projection url
Applet links
Applet repository - Working & Source

All open in a new window

Dibuixem polígons - run Simple Polygons applet - OK
Random position text
Simula vida - run LifeApplet applet - OK
Dibuixem un arbre - run Tree applet - OK
Cercles de colors - run ColorCircles applet - OK
Traffic Control - url

Origin URLs :


Location :
  • P4 : c:\Sebas\Java\Applets\
  • \\Java\AppletCode\


Servlet's

Servlets are Java applications that are executed on a server. Unlike applets, which are executed on a client, servlets have much more access to network and disk resources. Unlike CGI scripts, servlets don't require a separate process for each connection.

Domino

Beginner Java Programming for Notes Domino 6

Intermediate Java Programming for Notes Domino 6

Use External Java Classes in Domino Agents

The ins and outs of using Java with Domino

java MQIVP - located at \\t30\E:\MQ\Tools\Java\base

To trace the MQIVP program, enter : java MQIVP -trace n
where n goes from 1 to 5 (the greater the number, the more information is gathered)


Sigles, etc


Using JavaBeans

A JavaBean is a special type of Java class that you can use in several interesting ways to simplify program development. Some beans, such as Swing components, are designed to be visual components that you can use in a GUI editor to quickly build user interfaces. Other beans, known as Enterprise JavaBeans, are designed to run on special EJB servers and can run the data access and business logic for large Web applications.

In this chapter, I look at a more modest type of JavaBean that's designed to simplify the task of building Java Server Pages. In a nutshell, you can use the simple JavaBeans to build Java Server Pages without writing any Java code in the JSP itself. JavaBeans let you access Java classes by using special HTML-like tags in the JSP page.

What Is a JavaBean?

Simply put, a JavaBean is any Java class that conforms to the following rules:

Note that a class doesn't have to have any properties to be a JavaBean, but if it does, the properties have to be accessed according to this naming pattern. Also, not all properties must have both a get and a set accessor. A read-only property can have just a get accessor, and a write-only property can have just a set accessor.

REMEMBER - The property name is capitalized in the methods that access it, but the property name itself isn't. Thus setAddress sets a property named address, not Address.

That's all there is to it. More advanced beans can also have other characteristics that allow them to have a visual interface so they can be used drag-and-drop style in an IDE. And some beans implement an interface that allows their state to be written to an output stream so they can be re-created later. But those features are optional; any class that meets the three criteria stated here is a bean and can be used as a bean in JSP pages.

You've already seen plenty of classes that have methods with names like getCount and setStatus. These names are part of a design pattern called the Accessor pattern, which is covered in Book III, Chapter 2. Thus you've seen many examples of beans throughout this book, and you've probably written many bean classes yourself already.

REMEMBER - Any class that conforms to this pattern is a bean. There's no JavaBean class you have to extend, nor is there a Bean interface you have to implement to be a bean. All a class has to do to be a bean is stick to the pattern.

Java All-In-One Desk Reference For Dummies, Doug Lowe and Barry Burd.


EJB

Enterprise Java Bean (EJB) is a managed, server-sided component for modular construction of enterprise applications.
The EJB specification is one of the several Java APIs in the Java Platform, Enterprise Edition. EJB is a server-side component that encapsulates the business logic of an application.

Accordingly, the EJB specification details how an application server provides:

Additionally, the Enterprise JavaBean specification defines the roles played by the EJB container and the EJBs as well as how to deploy the EJBs in a container.

An EJB container can hold three major categories of beans:

Stateless Session Beans are distributed objects that do not have state associated with them thus allowing concurrent access to the bean. The contents of instance variables are not guaranteed to be preserved across method calls. The lack of overhead to maintain a conversation with the calling program makes them less resource-intensive than stateful beans.

Stateful Session Beans are distributed objects having state, that is, they keep track of which calling program they are dealing with throughout a session.

Entity Beans are distributed objects having persistent state.

Message Driven Beans are distributed objects that behave asynchronously, that is, they handle operations that do not require an immediate response. These beans subscribe to JMS (Java Message Service) message queues or message topics. They were added in the EJB 2.0 specification to allow event-driven processing inside EJB Container. Unlike other types of beans, MDB does not have a client view (Remote/Home interfaces), i.e. clients can not look-up an MDB instance. It just listens for any incoming message on a JMS queue (or topic) and processes them automatically.

EJBs are deployed in an EJB container within the application server. The specification describes how an EJB interacts with its container and how client code interacts with the container/EJB combination.

Because these are merely Java interfaces and not concrete classes, the EJB container must generate classes for these interfaces that will act as a proxy in the client. Client code invokes a method on the generated proxies, which in turn places the method arguments into a message and sends the message to the EJB server.

url

MDB

A Message Driven Bean (MDB) is an Enterprise JavaBean (EJB) similar to a session bean, except it responds to a JMS message rather than an RMI event. MDBs were introduced in the EJB 2.0 specification which is supported by Java 2 Platform, Enterprise Edition 1.3 or higher. The message bean represents the integration of JMS (Java Message Service) with EJB to create an entirely new type of bean designed to handle asynchronous JMS messages.

url, url


Singleton

Most commonly, you implement a singleton in Java by having a single instance of the class as a static field. You can create that instance at class-loading time by assigning a newly created object to the static field in the field declaration :

public class MySingleton { private static MySingleton _instance = new MySingleton(); private MySingleton() { // construct object . . . } public static MySingleton getInstance() { return _instance; } // Remainder of class definition . . .

Alternatively, you can instantiate it lazily, on first demand. You keep the constructor private to prevent instantiation by outside callers.

public class MySingleton { private static MySingleton _instance; private MySingleton() { // construct object . . . } // For lazy initialization public static synchronized MySingleton getInstance() { if (_instance==null) { _instance = new MySingleton(); } return _instance; } // Remainder of class definition . . . }

url, url

Implementing the Singleton Pattern in Java :

/** * A utility class of which at most one instance can exist per VM. * * Use Singleton.instance() to access this instance. * */ public class Singleton { /** * The constructor could be made private * to prevent others from instantiating this class. * But this would also make it impossible to * create instances of Singleton subclasses. */ protected Singleton() { // ... } /** * A handle to the unique Singleton instance. */ static private Singleton _instance = null; /** * @return The unique instance of this class. */ static public Singleton instance() { if(null == _instance) { _instance = new Singleton(); } return _instance; } /. ...additional methods omitted... }

url

Una altra descripció :

url


Snoop

Paco : IE ( http://localhost:9080/Snoopy/SnoopyTestServlet )

public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException { // TODO Apéndice de método generado automáticamente arg1.getOutputStream().print("<HTML>"); arg1.getOutputStream().print("<HEAD>"); arg1.getOutputStream().print("<TITLE> Pagina Snoop d'en Sebas i en Fernando. </TITLE>"); arg1.getOutputStream().print("</HEAD>"); arg1.getOutputStream().print("<BODY>"); arg1.getOutputStream().print("<HR>"); arg1.getOutputStream().print("Que passa Sebas ! Com estas ?"); arg1.getOutputStream().print("<HR>"); arg1.getOutputStream().print("Properties List es : <BR>"); System.getProperties().list(new PrintStream(arg1.getOutputStream())); arg1.getOutputStream().print("<HR>"); arg1.getOutputStream().print("JAVA.CLASS.PATH es : <BR>"); arg1.getOutputStream().print( System.getProperties().getProperty("java.class.path")); arg1.getOutputStream().print("</BODY>"); arg1.getOutputStream().print("</HTML>"); }

JJ : IE ( http://localhost:9080/Snoopy/SnoopyJSP.jsp )

 System.out.println("HOLA. +++ Voy a buscar SnoopyJSP.jsp ...");
 arg0.getRequestDispatcher("SnoopyJSP.jsp");
 System.out.println("HOLA. --- He vuelto de buscar SnoopyJSP.jsp ...");


Cridem a un JAVA des un JSP

SnoopyBean.java :

public class SnoopyBean {

     /*
      * ...
      */

     public SnoopyBean() {
          super();
          // TODO Apendice de constructor generado automáticamente
     }

     public String getText() {
          System.out.println("HOLA. +++ Voy a retornar un String ...");
          return "El Paco es collonut ... (version DEMO) ";
     }

SnoopyJSP.jsp :

 </HEAD>
 <f:view>
     <BODY>

     <jsp:useBean id="SnoopyBean" class="pagecode.SnoopyBean" scope="page">
     </jsp:useBean>
     <jsp:getProperty name="SnoopyBean" property="text"/>

     <p> Hola Sebas !
     <P> Fet per en Paco el 2 del 3 de 2006.</P>

     </BODY>
 </f:view>
 </HTML>


Envir var(s)

Abans :

103 if ( StrCodSvr.equals ( "ADP_ECO_WAS" ) )

Després :

public class MdbsvrBean implements javax.ejb.MessageDrivenBean, javax.jms.MessageListener { public static final String ECO_ID_PARAM = "ECO_ID"; protected String ecoId = null; . . . public void ejbCreate() { ecoId = System.getProperty(ECO_ID_PARAM); ecoId = ecoId!=null ? ecoId : "ADP_ECO_WAS"; . . . if ( StrCodSvr.equals( ecoId ) ) . . . rspmq.exec_snd(StrEntDst,StrEntOrg,StrTypMsg,"C", DatUsr, "Eco MDB J2EE V2 " + DtaMsg);

Que es configura passant-li paràmetres a la JVM :

-DECO_ID="ADP_ECO_WAS01"

JVM parameters in WAS

JVM arguments are used for configuring how the JVM executed. Any changes to JVM arguments needs restart of that JVM.

WebSphere Application Server 7.0

  1. In the Administration Console select Servers
  2. Expand Server Type and select WebSphere application servers
  3. Click on the name of your server
  4. Expand Java and Process Management and select Process Definition > Java Virtual Machine
  5. Scroll down and locate the textbox for Generic JVM arguments.

WebSphere Application Server 6.1

  1. In the Administration Console select Servers
  2. Select Application Servers
  3. Click on the name of your server
  4. In the Additional Properties section, expand Java and Process Management and select Process Definition > Java Virtual Machine
  5. Scroll down and locate the textbox for Generic JVM arguments.

WebSphere Application Server 6.0

  1. In the Administration Console select Servers
  2. Select Application Servers
  3. Click on the name of your server
  4. Under Server Infrastructure, expand Java and Process Management, and click Process Definition.
  5. Under the Additional Properties section, click Java Virtual Machine
  6. Scroll down and locate the textbox for Generic JVM arguments.

Gracias, Francisco !


RedBooks

  Uns quants tutorials que poden ser d'interès ...

Building Java HTTP servlets
This tutorial teaches basic concepts about servlets: what, why, and how. It also gives you some practical experience writing simple HTTP servlets. The tutorial includes three servlets (and their code) to demonstrate typical scenarios.
El tutorial més bàsic. Començar pel començament. Desevolupament de servlets. Lo primer que cal entendre per poder fer aplicacions web.
J2EE Tutorial
Un tutorial de J2EE, bastant bo. De Sun. Amb eines de Sun, però amb una bona introducció als conceptes principals de J2EE, desenvolupmanent, organització de components, desplegament, etc. [1447 pages, \\Java\LlibresJAVA\]
An introduction to the Eclipse Web Tools Platform V1.0
The Eclipse Web Tools Platform (WTP) extends the Eclipse IDE to enable easy development of Java 2 Enterprise Edition (J2EE)-based applications. Learn how to install WTP, configure it for use with an application server, and use the tools it provides to create a J2EE application.
Un pas més, afegint eines. Però no productes IBM, sinó eines "open source". Eclipse, Derby, JBoss.
Build dynamic Web sites
This tutorial shows you how to use IBM Rational Application Developer V6.0 to build dynamic Web sites. The tutorial walks you through a simple example that uses Java servlets and JavaServer Pages to implement a simple messaging center. You'll learn how to use Rational Application Developer to develop a dynamic Web site, then test and debug your code.
Introducció del RAD. Interessant. Potser podria ser el tutorial a seguir pas a pas, després de mirar-te una mica els dos anteriors.

Versions : JDK, .JAR ...

JDK 6
CheckList
JARe
jarversion <full_path>\sapjco.jar

des-compilar Java

Amunt! Top Amunt!
Java is losing the battle for the modern Web. Can the JVM save the vendors?

A few years ago I worked on a very big Enterprise IBM Websphere project. We had some brilliant engineers in the project both in the development and architecture groups. I remember having had several discussions with some of the brightest people on the team regarding PHP and dynamic languages and generally they were looked upon as toy languages without a bright future. Lack of strict typing, scripting performance, and other reasons were given for why Java would persevere as the language of choice.

This was the typical reaction dynamic languages would get from the Java community. There were many believable reasons for why these languages, especially the ones gaining fame on top of the LAMP stack, would not last. However, one thing which the Java community ignored for many years was the radical shift to the Web, not only for media and e-commerce Web sites but for a large majority of business applications including CRM, ERP, reporting, document management, etc As a result Java EE (then called J2EE) was not built with the Web in mind but rather focused on enterprise integration, transaction management and other back-end processing. While Java EE has long supported Web development with servlets and JSP the companies driving the standards ignored the RESTful nature of the Web and rather continued to drive a general purpose platform.

In parallel, the LAMP-like architecture built on top of the C language's eco-system of libraries and tools started becoming the most popular platform for developing Web applications. This trend grew in the second half of the 90s and with a recession following the burst of the .com bubble it greatly accelerated due to the lower TCO that the LAMP solutions had to offer. While there are a variety of dynamic languages which make up the LAMP development and deployment paradigm, the most ubiquitous language has been PHP. As a result of PHP being domain specific to the Web it has been shaped in a way which makes it fit the Web paradigm like a glove. By focusing on solving the common Web patterns quickly and easily it holds the biggest market share on the Web. In two separate surveys of one of the most popular Ajax Web sites, the Ajaxian.com, around 50% of Rich Internet Applications developers are using PHP. The trend has also been significantly accelerated as a result of the many popular PHP packages including Wordpress, Drupal, mediaWiki, osCommerce, SugarCRM, and more

When it became apparent to the large Java vendors that the Web paradigm was being built and innovated without Java they started backing a variety of both standards and non-standards driven Java Web application frameworks which promised to adapt Java to the Web. Such frameworks included Java Server Faces, Struts, Spring MVC and others. Some of these frameworks have been more successful than others but in general none of them managed to resolve one of Javas main pain points on the Web. The strict typing and overly complex architecture of Java applications meant longer development times and a need for more skilled engineers in order to push Java applications into the market, i.e. Java's TCO on the Web was unsatisfactory.

In the meanwhile the large Java vendors were trying to hold the stick at both ends. On one hand trying to be part of the Web paradigm shift and on the other hand protecting their multi-billion dollar businesses built on the Java language. Even the pervasiveness of dynamic languages in the Web space didn't change the vendor's behavior significantly. The big change came when Microsoft aggressively pursued a multi-language runtime environment for the .NET platform. Not only did they support C# and VB on their virtual machine but they worked with their developer community to add a large amount of languages including Cobol, Eiffel, Ruby, Python, and others. As dynamic languages continued to grow to the point where industry analysts started defining categories (e.g. Forrester Research on dynamic languages) Microsoft continued to leverage their common runtime which was designed from the get go to support multiple languages.

As mentioned earlier the de-facto standard implementations of the successful dynamic languages including PHP, Perl, Python and Ruby are all written in C and leverage the breadth and depth of the eco-system of C libraries. As community driven projects these languages do not have a specification nor is their development hindered by corporate bureaucracy. On the contrary, these languages are being developed by their users who have only one end goal get the job done, quickly As a result the languages are constantly evolving often adding significant enhancements in minor releases. With the rapid changes in how modern Web applications are being built and deployed this agile nature is a must-have to keep up with the latest trends.

In addition, the LAMP deployment paradigm has significant advantages. By featuring a multi-process architecture, faults in the Web Server and dynamic language software will typically not lead to sites going down. While one process may crash all other processes serving Web requests will continue running. This is in contrast to multi-threaded environments like the JVM (Java Virtual Machine, Java's execution environment) where software faults including crashes and deadlocks will typically lead to system down situations. In addition, the ability to recycle processes after a set time will prevent memory leaks and memory fragmentation, two common software memory problems, from degrading the system efficiency over time. Another key advantage LAMP developers enjoy is the easy deployment paradigm. Software updates can easily and incrementally be pushed out to LAMP servers without requiring prolonged build and packaging processes. While this may lead to unorthodox and sometimes too lax of a process, when done correctly it makes the lives of the developers and the operations personnel much easier.

While LAMP's growth was fueled by many of these development and deployment advantages, the Java vendors were stuck with the JVM which was very closely aligned to the Java language and had little support for targeting multiple languages. Instead of shifting towards a loosely coupled model of LAMP technology and Java technology in order to deliver the best of both worlds to their customers, most hesitated to lose control over the customer's workload and entered an arms race to deliver dynamic languages on top of the JVM. With Microsoft on one side and the Java competitors on the other, each vendor set out to develop their own dynamic languages strategy.

Today Sun is investing in JRuby (Ruby) and Jython (Python) support for its Java EE solution; the IBM Websphere group has realized the ineffectiveness of the Java EE platform for running modern Web workloads and has invested heavily in Project Zero which aims to make big blue a Web 2.0 player and initially delivers support for Groovy and PHP; BEA has also had some incubation projects going but with the upcoming sale to Oracle it is unclear whether any of those efforts will materialize. Project Zero's Chief Architect is one of the first IBMers to admit in public that Java today can be considered as a system language and is not desirable for building RESTful Web applications which is Project Zero's goal (slide #4 of the presentation- see slide #11 to see how a simple "Hello, World" in Java compares to dynamic languages like Groovy and PHP). It has taken over 10 years for the Java stronghold to admit Java's poor ROI on the Web and with the current recession it is likely that many Java customers are going to be making more informed investments. As a result there will be considerable rise in uptake of dynamic languages. Similar to the mainframe Java is heavily entrenched in enterprise IT and business-critical applications and is therefore not going away. That said for fueling modern Web applications the Java language will likely see a steep decline in market share.

The question to be asked is whether the non-Microsoft Web market will buy into the JVM implementations of dynamic languages or whether they will move to the LAMP stack which hosts the de-facto standards for the most popular languages. While I believe there will be customers who are attracted to the JVM implementations especially the ones who are heavily influenced by their relationships with the Java companies, the majority of the market is going to prefer to go down the route of the LAMP stack. Reasons include:

In conclusion, it is becoming clear that dynamic languages are going to increasingly become the standard for Web development. Microsoft and the Java vendors have all recognized this trend and are now aggressively pursuing solutions on top of their software stacks. However, as the core dynamic language communities thrive outside of the .NET CLR and Java JVM software stacks the vendors will be in a challenging position if they solely depend on the uphill battle of cloning the successful dynamic languages onto their software stacks. Some vendors are aware of this challenge and have built hybrid strategies which also aim to deliver the de-facto standard dynamic languages to their customers even if they don't have full synergy with their solution stack, this includes Microsoft's investment in making PHP work with their solution stack and Sun's initial attempts to deliver native Ruby and PHP implementations to their customer base. I believe that while the JVM approach to dynamic languages may appeal to some Java customers it will never be able to catch up with the broader open-source movement around native dynamic languages implementations. The JVM dynamic languages implementations will not be enough for the Java vendors to catch up and they will need to embrace the native de-facto standard community driven dynamic languages.

posted by Andi Gutmans @ 3/24/2008 11:07:00 AM

URL


64-bit OS vs 32-bit browser

We have detected you may be viewing this page in a 32-bit browser. If you use 32-bit and 64-bit browsers interchangeably, you will need to install both 32-bit and 64-bit Java in order to have the Java plug-in for both browsers.

Verify installed Java


Amunt! Top Amunt!
Java GUI development using Eclipse
from here

Estupideses
Class names, 'HelloWorld', are only accepted if annotation processing is explicitly requested

You forgot to include the .java suffix when compiling the program. Remember, the command is "javac HelloWorldApp.java" not "javac HelloWorldApp"

Error: Could not find or load main class my.samples.SimplePTP

El fitxer es diu SimplePTP i dintre porta

package my.samples ;
java.lang.NoClassDefFoundError

Add the location of your .class file to your classpath

java -cp . NomFitxerClass {sense extensio}

Amunt! Top Amunt!
Jython

Jython script to create a server, file create_server.py

#-------------------------------------------# import sys,java from java.util import Properties from java.io import FileInputStream from org.python.modules import time lineSep = java.lang.System.getProperty('line.separator') def server_create(node,server): node=AdminConfig.getid('/Node:'+node+'/') attr=[['name', server]] print "creating server .." AdminConfig.create('Server',node,attr) print "server created .." AdminConfig.save() print "saving config .." arglen=len(sys.argv) number_of_argument=2 if ( arglen != number_of_argument): print "pass 2 arguments .." sys.exit(-1) server=sys.argv[0] node=sys.argv[1] server_create(node,server) #----------------------------------------#

Execute it using wsadmin:

./wsadmin.sh -f create_server.py -lang jython -port 8879 -conntype SOAP -user wasadmin -password wasadmin test_server test_node

Jython Script to check the status of listener ports of all servers of cluster

lineSeparator = java.lang.System.getProperty('line.separator') clusterName='CLUSTER_NAME' cId = AdminConfig.getid("/ServerCluster:"+ clusterName +"/" ) cList = AdminConfig.list("ClusterMember", cId ).split(lineSeparator) for sId in cList: server = AdminConfig.showAttribute(sId, "memberName" ) node = AdminConfig.showAttribute(sId, "nodeName" ) cell = AdminControl.getCell() s1 = AdminControl.completeObjectName('cell='+ cell +',node='+node +',name='+ server +',type=Server,*') if len(s1) > 0: print server + " state is started" else: print server + " is down" print "Server " + server + " has the following Listener Ports" lPorts = AdminControl.queryNames('type=ListenerPort,cell='+ cell+',node='+ node +',process='+ server +',*') lPortsArray = lPorts.split(lineSeparator) for lPort in lPortsArray: lpcfgId = AdminControl.getConfigId(lPort) lpName = AdminConfig.showAttribute(lpcfgId, "name") lpstate = AdminControl.getAttribute(lPort, 'started') if lpstate == 'true': print lpName + " is started " else : print lpName + " is stopped " print ""

Dubtes, temes pendents

Links


Ep !

Valid HTML 4.01!   Valid CSS!

Site under construction. Escriu-me !
Updated 20141209 (a)  
Uf !