30 dezembro 2013

Web Article - Java questions


  1. What can be learned from “Hello World”?
  2. How to build your own library?
  3. Whan and how a class is loaded and initialized?
  4. Static Type Checking
  5. How to get double?
  6. What is string immutability?
  7. How does substring() work in Java
  8. Why string is immutable in Java?
  9. Is string passed by reference?
  10. length vs length()
  11. What exactly is null in Java?
  12. Comparator vs. Comparable
  13. The contract between hashCode() and equals()
  14. Overloading vs Overriding
  15. What is instance initializer?
  16. Fields can not be overridden?
  17. How many types of inner classes?
  18. What is Inner Interface in Java?
  19. Constructors of Sub and Super classes?
  20. Public, protected, and private
  21. When to use private constructors?
  22. How exception handling works?
  23. Class hierarchy of exceptions
  24. How file reading/writing works in Java?
  25. Read file line by line
  26. Write file line by line
  27. FileOutputStream vs. FileWriter
  28. Should .close() be put in finally block or not?
  29. How to use properties file?(explain the code)
  30. When multithreading is useful?
  31. Monitors – The Basic Idea of Java synchronization
  32. Class hierarchy of Collection and Map
  33. A TreeSet Example
  34. Deep Understanding of Arrays.sort(T[], Comparator < ? super T > c)
  35. ArrayList vs. LinkedList vs. Vector
  36. HashSet vs. TreeSet vs. LinkedHashSet
  37. HashMap vs. TreeMap vs. HashTable vs. LinkedHashMap
  38. Efficient Counter in Java
  39. Frequently Used Methods of Java HashMap
  40. What is Type Erasure?
  41. Why do we need Generic Types in Java?
  42. Set vs. Set
  43. Use Map or HashMap as declaration types?
  44. What’s the best way of converting Array to ArrayList?
  45. Java passes object by reference or by value?
  46. Reflection tutorial
  47. What is framework?
  48. Why do we need Java web frameworks like Struts 2?
  49. What is JVM?
  50. JVM run-time data areas
  51. How GC works?
  52. How does Java handle aliasing?
  53. What does an array look like in memory?
  54. What is memory leak?
  55. What is Servlet Container? What is Tomcat?
  56. What is Aspect Oriented Programming?
  57. Library vs. Framework?
  58. Java and Computer Science Courses
  59. How Compiler Works?
    Type Checking for Object Oriented Features
  60. Generate Code for Overloaded and Overridden Methods?
  61. Top 10 Methods for Java Arrays
  62. Top 10 questions of Java Strings
  63. Top 10 Questions for Java Regular Expression
  64. Top 10 Questions about Java Exceptions
  65. Top 10 questions about Java Collections
  66. Top 9 questions about Java Maps
  67. The Most Widely Used Java Libraries
  68. ———————————————————————-
  69. Top 10 Websites for Advanced Level Java Developers
  70. Top 10 Books For Advanced Level Java Developers
  71. High-quality Java blogs
  72. Java vs. Python: Basic SyntaxDate Types
  73. How to write a crawler in Java?
  74. 8 Things Programmers Can Do at Weekends
  75. Blogging Tips
  76. Some notes for SCJP
  77. Some notes about Declaration, Initialization and Scoping
  78. Open Source Projects Using Spring Framework
  79. Design Patterns in Stories
  80. Spring
  81. Struts 2
  82. Guava
  83. Log4j
  84. JSoup
  85. Swing
  86. Create thread by overriding(another way, difference)
  87. join()
  88. notify() and wait() (output use other format maybe)
  89. Date Formatting(add more)
  90. Path of package and class
  91. Iteration vs. Recursion
  92. Why do we need reflection? (add more)
  93. Top 10 algorithms for coding interview
  94. How CVS works?
  95. Top 8 Diagrams for Understanding Java
  96. Why do we need software testing?
  97. Convert java jar file to exe

20 dezembro 2013

Application - BareTail

Real-time file viewing
  • Optimised real-time viewing engine
  • View files of any size (> 2GB)
  • Scroll to any point in the whole file instantly
  • View files over a network
  • Configurable line wrapping
  • Configurable TAB expansion
  • Configurable font, including spacing and offset to maximise use of screen space

19 dezembro 2013

17 novembro 2013

Web Tutorials

Web Tutorials

JAVA
Simple Java Database Swing Application
How to Send Email from Java Program with Example
Java ResourceBundle Example

Creating Maven Projects
Hibernate 3 with Maven 2 and MySQL 5 Example (XML Mapping and Annotation)
How to create a EJB 3.x project using Maven in Eclipse – Part 1
Setup of Dynamic Web Project using Maven
Create Web Application Project with Maven Example

JMS
Spring JMS Example

Java EE7 and Maven
Java EE7 and Maven project for newbies - part1 part2 part3 part4 part5 part6 part7 part8
Spring JPA Data + Hibernate + MySQL + MAVEN
Spring MVC Hello World Example
Spring MVC File Upload Example
Spring MVC beginner tutorial with Spring Tool Suite IDE
Upload Files to Database with Spring MVC and Hibernate

Logging 
Logback
Logback Configuration Example

WELD - Java Contexts and Dependency Injection for the Java EE platform (CDI)
DI (Dependency Injection) / CDI – Basics
Writing JSR-352 style jobs with Spring Batch Part 2: Dependency injection

Spring Data MongoDB
Spring Data MongoDB with Java config

JPA
JPA Tutorial: Setting Up JPA in a Java SE Environment
JPA Tutorial: Mapping Entities – Part 1 - Part 2 - Part 3

Hibernate
Hibernate annotations example
Hibernate tutorial with Eclipse

Persistence
The DAO with JPA and Spring
How to maintain history of tables in Hibernate

Android Tutorials
Android Development Tutorial

07 novembro 2013

Java Tutorials


Java Excel “Apache POI”
Apache POI – Java Read & Write Excel





Source: Hmkcode

02 novembro 2013

My bikes


Road Bike
Orbea Aqua T105 CT 2010
Frame type: Rigid
Frame material: Aluminium
Gears: 20
Wheel size: 700C
Brakeset: ORBEA PRO SILVER
Chainset: SHIMANO R600 34x50 CT
Front Derailleur: Shimano 105
Rear Derailleur: Shimano Ultegra
Shifters: SHIMANO 105
Cassette: Shimano 105
Wheels: SHIMANO WH-R500 BLACK
Frame Description: ORBEA AQUA - Double thickness 7005 aluminium, T6 heat treatment, Orbea Carbon Bronze monocoque fork
Frame construction: TIG Welding
Cassette (Rear Cogs): SHIMANO 105 12-25 10S
Chain: KMC DX-10
Crank: SHIMANO R600 34x50 CT
Pedals: LOOK KEO EASY
Derailleur Front: SHIMANO 105
Derailleur Rear: SHIMANO ULTEGRA
Extras: Hand-painted in a choice of four colours
Handlebar: ORBEA ROAD
Headset: SEMIINTEGRATED BLACK
Rigid Forks: ORBEA CARBON
Saddle: SELLE ITALIA X2 PRO
Seat Post: ORBEA CARBON
Stem: ORBEA ALU
Technologies: Double butted aluminium, T6 heat treatment, monocoque fork
Use: Leisure sport and initiation
Weight: 9.220 kg
Tyres (Front & Back): VITTORIA ZAFIRO 700x23
Type: Road / Racing
Gender/age: Men

23 outubro 2013

Web Article - JSF Tomcat Configuration Example

In this example we can view how configure JSF with Tomcat application server.
For this was created a simple project using JSF and then deployed it in tomcat server.

View Example

16 outubro 2013

Video - JVM

Em sua apresentação no 7Masters Java, em novembro do ano passado, falou sobre JVM e a linguagem para qual ela foi desenvolvida, o Java.
Source

04 outubro 2013

Default CDI Enablement in Java EE 7

CDI provides control over component scanning via the 'bean-discovery-mode' attribute. This attribute has three possible values:
  • annotated - loosely translated, means that only components with a class-level annotation are processed.
  • all - all components are processed, just like they were in Java EE 6 with the explicit beans.xml.
  • none - CDI is effectively disabled.

Source: The Aquarium

02 outubro 2013

Stress-Testing Java EE 6 Applications Without Stress

About movie:
In the context of Java EE 6, unit tests are nice but worthless. Unit and integration tests execute chunks of the business logic in a single thread. Back-end resources and shared states are simulated with mocks. After the initial deployment, your application will never be executed again in a single thread. Strangely enough, most applications aren't load-tested until shortly before the deadline and are put into production regardless of the results. This session shows how to continuously stress-test your Java EE applications with open source tools and lots of fun!

24 setembro 2013

Web Article - Connect SQLite Database with a Remote Shell

In this article see:
  • How to connect to a sqlite database existing on Android devices from your PC?
  • How to interact with Android sqlite database from remote shell?

Full article in HMKCode

21 setembro 2013

Web Article - Questions about Java Strings

1. How to compare strings? Use “==” or use equals()?

2. Why is char[] preferred over String for security sensitive information?

3. Can we use string for switch statement?
// java 7 only!
switch (str.toLowerCase()) {
      case "a":
           value = 1;
           break;
      case "b":
           value = 2;
           break;
}

4. How to convert string to int?
int n = Integer.parseInt("10");

5. How to split a string with white space characters?
String[] strArray = aString.split("\\s+");

6. Does substring() method create a new string?
str.substring(m, n) + ""

7. String vs StringBuilder vs StringBuffer 

8. How to repeat a string?
String str = "abcd";
String repeated = StringUtils.repeat(str,3);
//abcdabcdabcd

9. How to convert string to date?
String str = "Sep 17, 2013";
Date date = new SimpleDateFormat("MMMM d, yy", Locale.ENGLISH).parse(str);
System.out.println(date);
//Tue Sep 17 00:00:00 EDT 2013

10. How to count # of occurrences of a character in a string?
int n = StringUtils.countMatches("11112222", "1");
System.out.println(n);

A method to detect if string contains only uppercase letter in Java
public static boolean testAllUpperCase(String str){
  for(int i=0; i < str.length(); i++){
   char c = str.charAt(i);
   if(c >= 97 && c <= 122) {
    return false;
   }
  }
  //str.charAt(index)
  return true;
 }
Source: http://www.programcreek.com/

20 setembro 2013

Web Article - OmniFaces goes CDI





"Finally, OmniFaces 1.6 has been released! With this release, OmniFaces features for the first time CDI-related features:


Full article in The Balusc Code

13 setembro 2013

Web Article - Build offline with maven


"Sometimes I work at home and sometimes I’ve no VPN connection to my company. Sometimes I sit in a hotel without any internet connection. But I want to compile my projects with maven."

Full article here.

12 setembro 2013

Web Article - Some Interview Questions to Hire a Java EE Developer

"Some examples of interview questions that check the knowledge of the candidate based on his/her experience. The questions were formulated to verify whether the candidate is capable of fulfilling the role of a Java enterprise applications developer." 


Questions:
1. Can you give some examples of improvements in the Java EE5/6 specification in comparison to the J2EE specification?
2. Considering two enterprise systems developed in different platforms, which good options do you propose to exchange data between them?
3. What do you suggest to implement asynchronous code in Java EE?
4. Can you illustrate the use of Stateless Session Bean, Stateful Session Bean and Singleton Session Bean?
5. What is the difference between queue and topic in a message queuing system?
6. Which strategies do you consider to import and export XML content?
7. Can you list some differences between a relational model and an object model?
8. What is the difference between XML Schema, XSLT, WSDL and SOAP?
9. How would you configure an environment to maximize productivity of a development team?

Full article here.

11 setembro 2013

Revista Programar - 42ª Edição - Setembro 2013



Nesta edição como artigo de capa, um artigo sobre Web Persistente: Local Storage de Telmo Marques. Nesta 42ª edição pode ainda encontrar os seguintes artigos:
  • Debug de Aplicações em C (António Pedro Cunha)
  • Arduino: Accionamento e Controlo de Servos Via Teclado (Nuno Santos)
  • Introdução ao Web2py (António Santos)
  • Listas Simplesmente Ligadas e Exemplo de Implementação em C (Cristiano Ramos)
  • Pascal - Tipos de Dados Variant e Tipos Genéricos (Igor Nunes)
  • Visual(not)Basic - Eventos e handlers (Sérgio Ribeiro)
  • Windows Server 2012 - Curso Completo (Nelson Belo Lima)
  • Redes de Computadores - Curso Completo (António Santos)
  • Implementando publicidade usando Nokia NAX em aplicações Windows Phone (Sara Silva)
  • Navicat Premium 11 (Nelson Belo Lima)
  • Dispositivo Android: Ser ou Ser reconhecido pela Google (Rita Peres)

08 setembro 2013

Web Article - How Maven find dependency JARs while building Java Project

"One of the most attractive feature of Apache Maven framework it to manage dependency JARs, but do you know, How Maven finds dependency JAR while building Java project?"

Read more here

24 agosto 2013

Configure and Create Maven test application

"Maven is the java build tool that helps the create enterprise application in the standard directory structure and resolve the dependency to compile and run the application. Maven is used to create deployable artifact. It is project management tool that provide build capabilities."

Full article here

13 agosto 2013

Free Java EE 6 Video Tutorial

Free online tutorial about JPA, EJB 3, JSF, JMS, JAX-RS and CDI. The tutorial starts from the very basics and teaches Java EE, API by API/feature by feature, through a series of progressive code examples that build on the one before it. The tutorial uses GlassFish, NetBeans and MySQL.

07 agosto 2013

The Java EE 7 Platform: Boosting Productivity and Embracing HTML5

About movie:
In this code-based presentation Oracle's Arun Gupta walks you through what's new in Java EE 7 and will show you how to boost productivity by taking advantage of certain APIs, like Processing, Caching, and much more!

15 julho 2013

Java EE 7 - Articles

A large collection of articles about Java EE 7 and its sub-specs, such as JSF 2.2, JPA 2.1, JMS 2.0, CDI 1.1, etc. The full articles here https://javaee7.zeef.com/.

13 julho 2013

11º Meeting PT.JUG

Apresentações do 11º meeting realizado a 3 de Julho de 2013.

09 julho 2013

Revista Programar - 41ª Edição - Junho 2013


Nesta edição como artigo de capa, um artigo sobre Introdução ao Java EE e Java Web de José Marques. Nesta 41ª edição pode ainda encontrar os seguintes artigos:

  • Programação em C: const (António Pedro Cunha)
  • Jogo da Vida (Rita Peres)
  • JBoss Aplication Server 7 (Mauricio Magnani Jr)
  • PHP: Uma framework “from scratch” (Parte 1) (Ricardo Perre)
  • C# - Observable vs. Task (Paulo Morgado)
  • Visual(not)Basic - Operator Overloading (Sérgio Ribeiro)
  • I Evento Presencial Programar
  • Android – Introdução ao Desenvolvimento de Aplicações (José Marques)
  • C# 5.0 com Visual Studio 2012 (Ricardo Perre)
  • NetPonto - Telerik RadControls - Rápida implementação da página Sobre para Windows Phone Apps (Sara Silva)
  • Game Salad (Rita Peres)
Download

01 julho 2013

Java EE 7 - Entreprise JavaBeans 3.2

About video: Enterprise JavaBeans is an architecture for the development and deployment of component-based applications. This webinar is an overview of the EJB 3.2: changes to the SFSBs and MDBs, security, TimerService API; optional features, and more.

Java EE 7 - Bean Validation 1.1

About video:
Bean Validation standardizes constraint declarations and validation for the Java platform.
In this webinar we will discuss via examples method-level validation, CDI integration and more in Bean Validation 1.1.

28 junho 2013

Java EE 7's JSF 2.2, Interceptors 1.2, and JPA 2.1 Intro Videos

Java EE 7 Launch Webinar sessions.

Here's the JSF 2.2 session:


Here's the Interceptors 1.1 session:


Here's the JPA 2.1 session:



27 junho 2013

EJB transactions: going deeper

In below article the autor explains in some words how works EJB technology, particularly about EJB transaction management
Full article
@Stateless  
public class MyFirstEjbBean implements MyFirstEjb {  
  
  @EJB  
  private MySecondEjb other;  
  
  public void firstEjb(){  
  
    other.secondEjb();  
  }  
}  
  
  
@Stateless  
public class MySecondEjbBean implements MySecondEjb {  
  
  public void secondEjb(){  
  
  }  
} 

22 junho 2013

Hibernate - Callback methods

Callbacks Methods: It is often useful for the application to react to certain events that occur inside the persistence mechanism.


TypeDescription
@PrePersistExecuted before the entity manager persist operation is actually executed or cascaded. This call is synchronous with the persist operation.
@PreRemoveExecuted before the entity manager remove operation is actually executed or cascaded. This call is synchronous with the remove operation.
@PostPersistExecuted after the entity manager persist operation is actually executed or cascaded. This call is invoked after the database INSERT is executed.
@PostRemoveExecuted after the entity manager remove operation is actually executed or cascaded. This call is synchronous with the remove operation.
@PreUpdateExecuted before the database UPDATE operation.
@PostUpdateExecuted after the database UPDATE operation.
@PostLoadExecuted after an entity has been loaded into the current persistence context or an entity has been refreshed.

Example
@Entity
@EntityListeners(class=Audit.class)
public class Cat {
    @Id private Integer id;
    private String name;
    private Calendar dateOfBirth;
    @Transient private int age;
    private Date lastUpdate;
    //getters and setters

    /**
     * Set my transient property at load time based on a calculation,
     * note that a native Hibernate formula mapping is better for this purpose.
     */
    @PostLoad
    public void calculateAge() {
        Calendar birth = new GregorianCalendar();
        birth.setTime(dateOfBirth);
        Calendar now = new GregorianCalendar();
        now.setTime( new Date() );
        int adjust = 0;
        if ( now.get(Calendar.DAY_OF_YEAR) - birth.get(Calendar.DAY_OF_YEAR) < 0) {
            adjust = -1;
        }
        age = now.get(Calendar.YEAR) - birth.get(Calendar.YEAR) + adjust;
    }
}

public class LastUpdateListener {
    /**
     * automatic property set before any database persistence
     */
    @PreUpdate
    @PrePersist
    public void setLastUpdate(Cat o) {
        o.setLastUpdate( new Date() );
    }
}


Source

12 junho 2013

Java EE 7 is final

Here is what EE 7 looks like as of today

The complete specification now contains 34 individual specifications.
SpecificationJSRVersionJava.net Project
Java Platform, Enterprise Edition3427javaee-spec
Managed Beans3421.0
Java EE Web Profile (Web Profile)3421.0
Java API for RESTful Web Services (JAX-RS)3392.0jax-rs-spec
Web Services for Java EE1091.4
Java API for XML-Based Web Services (JAX-WS)2242.2jax-ws
Java Architecture for XML Binding (JAXB)2222.2jaxb
Web Services Metadata for the Java Platform1812.1
Java API for XML-Based RPC (JAX-RPC) (Optional)1011.1jax-rpc
Java API for XML Registries (JAXR) (Optional)931.0
Servlet3403.1
JavaServer Faces(JSF)3442.2javaserverfaces
JavaServer Pages (JSP)2452.3
JavaServer Pages Expression Language (EL)3413.0el-spec
A Standard Tag Library for JavaServer Pages (JSTL)521.2jstl
Debugging Support for Other Languages451.0
Contexts and Dependency Injection for the Java EE Platform (CDI)3461.1github.com
Dependency Injection for Java (DI)3301.0
Bean Validation3491.1http://beanvalidation.org
Enterprise JavaBeans (EJB)3453.2ejb-spec
Java EE Connector Architecture (JCA)3221.7
Java Persistence (JPA)3382.1jpa-spec
Common Annotations for the Java Platform2501.2
Java Message Service API (JMS)3432.0
Java Transaction API (JTA)9071.2jta-spec
JavaMail9191.5javamail
Java Authentication Service Provider Interface for Containers (JASPIC)1961.1jaspic-spec
Java Authorization Contract for Containers (JACC)1151.5jacc-spec
Java EE Application Deployment (Optional)881.2
Java Database Connectivity (JDBC)2214.0
Java Management Extensions (JMX)2552.0openjdk
JavaBeans Activation Framework (JAF)9251.1
Streaming API for XML (StAX)1731.0sjsxp
Java Authentication and Authorization Service (JAAS)1.0
Interceptors3181.2
Batch Applications for the Java Platform3521.0jbatch
Java API for JSON Processing3531.0json-processing-spec
Java API for WebSocket3561.0websocket-spec
Concurrency Utilities for Java EE2361.0concurrency-ee-spec

Source

01 junho 2013

Setup of Dynamic Web Project using Maven

Good article that show how to create a Dynamic Web Project using Maven.
Full article here.

In same blog i found other interesting article about
Spring JPA Data + Hibernate + MySQL + MAVEN that show how we can develop a web-applications with the help of Spring MVC.

28 maio 2013

Live Webcast - Introducing Java EE 7 - 12, 13 June 2013


AGENDA
Keynote Address
  • With speakers from Oracle, IBM, Infosys and JUGs, including:
    • Hasan Rizvi, Executive Vice President, Oracle Fusion Middleware and Java, Oracle
    • Cameron Purdy, Vice President, Development, Oracle
    • Arun Gupta - Java EE & GlassFish Evangelist, Oracle
    • Linda DeMichiel, Specification Lead for Java Platform, Enterprise Edition 7, Oracle

On-Demand Breakout Sessions
  • 15 sessions featuring demos and details about each new JSR

Live Chat with Java Experts
  • Hour-long chats on the following topics:
    • Scalable, Dynamic HTML 5
    • Increasing Productivity
    • Meeting Enterprise Demands

More information here

09 maio 2013

The Java EE 6 - Using Scopes

Using Scopes
For a web application to use a bean that injects another bean class, the bean needs to be able to hold state over the duration of the user’s interaction with the application. The way to define this state is to give the bean a scope. You can give an object any of the scopes described in following table, depending on how you are using it.


Scope
Annotation
Duration
Request
@RequestScoped
A user’s interaction with a web application in a single HTTP request.
Session
@SessionScoped
A user’s interaction with a web application across multiple HTTP requests.
Application
@ApplicationScoped
Shared state across all users’ interactions with a web application.
Dependent
@Dependent
The default scope if none is specified; it means that an object exists to serve exactly one client (bean) and has the same lifecycle as that client (bean).
Conversation
@ConversationScoped
A user’s interaction with a JavaServer Faces application, within explicit developer-controlled boundaries that extend the scope across multiple invocations of the JavaServer Faces lifecycle. All long-running conversations are scoped to a particular HTTP servlet session and may not cross session boundaries.
The first three scopes are defined by both JSR 299 and the JavaServer Faces API. The last two are defined by JSR 299.

01 maio 2013

Java EE 7 Approved!

Java EE 7 is officially done as of this week. Linda DeMichiel just announced on the Oracle blog that the Java EE 7 Platform JSR, as well as the more compact Web Profile JSR for this EE version, have both been approved by the Java Community Process.

Here's the complete list of 14 JSRs and 9 MRs (maintenance releases):

JSRs:
  • Java Platform, Enterprise Edition 7 (JSR 342
  • Concurrency Utilities for Java EE 1.0 (JSR 236) (New to JEE!) 
  • Java Persistence 2.1 (JSR 338
  • JAX-RS: The Java API for RESTful Web Services 2.0 (JSR 339
  • Java Servlet 3.1 (JSR 340
  • Expression Language 3.0 (JSR 341
  • Java Message Service 2.0 (JSR 343
  • JavaServer Faces 2.2 (JSR 344
  • Enterprise JavaBeans 3.2 (JSR 345
  • Contexts and Dependency Injection for Java EE 1.1 (JSR 346
  • Bean Validation 1.1 (JSR 349
  • Batch Applications for the Java Platform 1.0 (JSR 352) (New to JEE!) 
  • Java API for JSON Processing 1.0 (JSR 353) (New to JEE!) 
  • Java API for WebSocket 1.0 (JSR 356) (New to JEE!) 

MRs:
  • Web Services for Java EE 1.4 (JSR 109
  • Java Authorization Service Provider Contract for Containers 1.5 (JACC 1.5) (JSR 115
  • Java Authentication Service Provider Interface for Containers 1.1 (JASPIC 1.1) (JSR 196
  • JavaServer Pages 2.3 (JSR 245
  • Common Annotations for the Java Platform 1.2 (JSR 250
  • Interceptors 1.2 (JSR 318
  • Java EE Connector Architecture 1.7 (JSR 322
  • Java Transaction API 1.2 (JSR 907
  • JavaMail 1.5 (JSR 919
Source: Dzone