11 dezembro 2014

Oracle Exam - Java SE 7 Programmer I | 1Z0-803


Exam Number :1Z0-803
Associated Certifications:Oracle Certified Associate, Java SE 7 Programmer
Duration:120 minutes
Number of Questions:70
Passing Score63% View passing score policy


Resources:
Book: OCA/OCP Java SE 7 Programmer I & II Study Guide

18 novembro 2014

Web Article - Top 10 Best free Rich Text Editors


1) Best Rich Text Editor – NicEdit

2) Rich Text Editor – Xinha
3) Free Rich Text Editor – WYSIWYG Editor
4) Best Web Text Editor- FCKeditor
5) Best Javascript Markup Editor – MarkITUp
6) Rich Text Editor – WidgEditor
7) Best Leading Text Editor – XStandard
8) Free Web Based Text Editor – Whizzywig
9) Best Web based XHTML Editor – WYMeditor
10) Top free Rich Text Editor – FreeTextBox

Source: Devzum.com

17 novembro 2014

08 novembro 2014

Web Article: Java Synchronized keyword Example

Example 1
package com.javacodegeeks.snippets.core.synchronizedexample;

import java.util.ArrayList;

public class SynchronizedMethodClass {

 private ArrayList < Integer > nums1;
 private String pos1;

    public SynchronizedMethodClass() {
     nums1 = new ArrayList < Integer >();
     nums1.add(0);
     pos1 = "0";
    }

 public ArrayList < Integer > getNums1() {
  return nums1;
 }

 public void setNums1(ArrayList < Integer > nums1) {
  this.nums1 = nums1;
 }

 public String getPos1() {
  return pos1;
 }

 public void setPos1(String pos1) {
  this.pos1 = pos1;
 }

 public synchronized void syncMethod(String threadName) {
     Integer number = nums1.get(nums1.size() - 1) + 1;
        pos1 = String.valueOf(number);
        nums1.add(number);
        System.out.println("Thread " + threadName + " : " 
+ nums1.get(nums1.size() - 1) + " - " + pos1);
    }
}
Example 2
package com.javacodegeeks.snippets.core.synchronizedexample;

import java.util.ArrayList;

public class SynchronizedBlockClass {

    private ArrayList < Integer > nums2;
    private String pos2;
    private int counter;
    
    public SynchronizedBlockClass() {
     nums2 = new ArrayList < Integer >();
     nums2.add(0);
     pos2 = "0";
    }
 
 public ArrayList < Integer > getNums2() {
  return nums2;
 }

 public void setNums2(ArrayList < Integer > nums2) {
  this.nums2 = nums2;
 }
 
 public String getPos2() {
  return pos2;
 }

 public void setPos2(String pos2) {
  this.pos2 = pos2;
 }

 public int getCounter() {
  return counter;
 }

 public void setCounter(int counter) {
  this.counter = counter;
 }

    public void syncBlock(String threadName) {
     counter++;
     System.out.println("Thread " + threadName + " - counter: " + counter);
        synchronized (this) {
         Integer number = nums2.get(nums2.size() - 1) + 1;
            pos2 = String.valueOf(number);
         nums2.add(number);
            System.out.println("Thread " + threadName + " Added to list: " 
              + nums2.get(nums2.size() - 1) + " - " + pos2);
           }
    }

}

Source: javacodegeeks

Web Article - ClassLoader Example

package com.jcg;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author ashraf
 * 
 */
public class JavaClassLoader extends ClassLoader {
 
 public void invokeClassMethod(String classBinName, String methodName){
  
  try {
   
   // Create a new JavaClassLoader 
   ClassLoader classLoader = this.getClass().getClassLoader();
   
   // Load the target class using its binary name
         Class loadedMyClass = classLoader.loadClass(classBinName);
         
         System.out.println("Loaded class name: " + loadedMyClass.getName());
         
         // Create a new instance from the loaded class
         Constructor constructor = loadedMyClass.getConstructor();
         Object myClassObject = constructor.newInstance();
         
         // Getting the target method from the loaded class and invoke it using its name
         Method method = loadedMyClass.getMethod(methodName);
         System.out.println("Invoked method name: " + method.getName());
         method.invoke(myClassObject);

  } catch (ClassNotFoundException e) {
   e.printStackTrace();
  } catch (Exception e) {
   e.printStackTrace();
  }
  
 }
}

Running the example
package com.jcg;


/**
 * @author ashraf
 * 
 */
public class ClassLoaderTest extends JavaClassLoader {

 public static void main(String[] args) {

  JavaClassLoader javaClassLoader = new JavaClassLoader();
  javaClassLoader.invokeClassMethod("com.jcg.MyClass", "sayHello");
  
 }
 
}

Source: javacodegeeks

04 novembro 2014

Adding a library/JAR to an Eclipse Android project

Steps:
  1. Download the library to your host development system.
  2. Create a new folder, libs, in your Eclipse/Android project.
  3. Right-click libs and choose Import -> General -> File System, then Next, Browse in the filesystem to find the library's parent directory (i.e.: where you downloaded it to).
  4. Click OK, then click the directory name (not the checkbox) in the left pane, then check the relevant JAR in the right pane. This puts the library into your project (physically).
  5. Right-click on your project, choose Build Path -> Configure Build Path, then click the Libraries tab, then Add JARs..., navigate to your new JAR in the libs directory and add it. (This, incidentally, is the moment at which your new JAR is converted for use on Android.)
NOTE
Step 5 may not be needed, if the lib is already included in your build path. Just ensure that its existence first before adding it.

Source: stackoverflow

31 outubro 2014

Web Article: Generic Method Example in Java

public static  < T > void sum(List  sumList)
{
 Number sum = 0;
 for (Number n : sumList)
 {
     sum = sum.doubleValue() + n.doubleValue();
 }
 System.out.println(sum);
}
public static void main(String[] args)
{
 List < Integer > integerList = new ArrayList < >();
 integerList.add(1);
 integerList.add(2);
 integerList.add(3);
 sum(integerList);

 List < Float > floatList = new ArrayList < >();
 floatList.add(1.2f);
 floatList.add(2.2f);
 floatList.add(3.4f);
 sum(floatList);
}



Source: javacodegeeks

17 outubro 2014

Web Tutorial - JSF 2.2 tutorial with Eclipse and WildFly


About tutorial:
"In this tutorial you will learn how to setup a JSF 2.2 (Mojarra) playground with Eclipse 4.4 (Luna) and WildFly 8.1. This tutorial assumes that you're starting from scratch and thus covers every single step necessary towards a working JSF web page."



13 outubro 2014

Web Article - Top Ten Untrodden Areas of Java




1. Generics
2. Threads
3. Concurrency
4. Reflection
5. Serialization
6. Regular Expression
7. Enumeration
8. Anonymous Inner Class
9. Garbage Collection
10. Bit Manipulation


10 outubro 2014

Revista PROGRAMAR - 46ª Edição - Setembro 2014



Tema de capa: Paralelização de Aplicações com OpenMP, de Rui Gonçalves. 

Poderá ainda encontrar nesta edição os seguintes artigos:
  • Gestão de projectos utilizando o Redmine (Anderson Freire)
  • Lua – Linguagem de Programação – Parte 12 (Augusto Manzano)
  • Como usar ler o ficheiro manifest usando o Cimbal ino Windows Phone Toolkit  (usando MVVM) (Sara Silva)
  • Classifique a sua App! (Daniel Marques)
  • CoreDump - Ensino Delta Empresa (Fernando Martins)
  • Desenvolvimento em iOS iPhone, iPad e iPod Touch – Curso Completo (3.ª Edição Atualizada) (Vitor Ferreira)
  • Comunidade  NetPonto — Autenticação usando a conta do Facebook, Google e Microsoft numa app de WP8.0 (Sara Silva)
  • Raspberry Pi em versão melhorada (Rita Peres)
  • jQuery: Usar ou não Usar? (Luis Soares)
  • Usar ou Não Usar Múltiplos Monitores Para Programar (Nuno Santos)
  • Tap Ballz (Sara Santos)

02 outubro 2014

Android LX - Descobre o que há de novo no Android - 14OUT2014


O Android LX está agendado para o próximo dia 14 de Outubro, no Hotel Florida, pelas 19h00 e, entre outras coisas, terá na agenda apresentações técnicas sobre desenvolvimento para Android.



12 setembro 2014

24 Horas de PASS - 7 e 8OUT2014


Sobre

24 horas de formação gratuita em SQL Server - Distribuída por 2 dias.

Bem-vindo ao mundo de 24 Horas de PASS!

Nos dias 7 e 8 de Outubro de 2014 realiza-se a terceira edição do "24 Horas de PASS" completamente em Português!

Com ínicio às 11:00 (BRT) / 15:00 (GMT), cada dia irá contar com 12 horas seguidas de apresentações sobre funcionalidades e técnicas de SQL Server com especial atenção para a nova versão - o SQL Server 2014 .

24 Horas de PASS é um evento online e gratuito, onde pode aprender com os melhores especialistas em SQL Server do mundo Lusófono, onde o Português é a lingua Oficial.

Mais de 20 especialistas em SQL Server do Brasil e de Portugal vão fazer apresentações técnicas focadas nos seguintes temas - Desenvolvimento (DEV), Administração (DBA), Business Intelligence (BI), Business Analytics(BA), PowerBI e Cloud. Temos uma extensa lista de "apresentadores especialistas", incluindo MVPs, MCMs e PFE's (Premier Field Engineer) da Microsoft.

Organizado pelas comunidades da PASS no Brasil e em Portugal este evento conta com o melhor que há de SQL Server de ambos lados de Atlântico.

24 horas de PASS é um evento que você não pode perder.

Toda a informação em

09 setembro 2014

Jodd - The Unbearable Lightness of Java

Jodd is set of Java micro frameworks, tools and utilities, under 1.5 MB. Designed with common sense to make things simple, but not simpler. Get things done. Build your beautiful ideas. Run your startup. And enjoy the coding.




Jodd utilities
BeanUtil - fastest bean manipulation library around.
Cache - set of common cache implementation.
Printf - formatted value printing, as in C.
JDateTime - elegant usage and astronomical precision in one time-manipulation class.
Type Converter - converting types.
StringUtil - more then 100 of additional String utilities.
StringTemplateParser - simple string template parser.
Finding, scanning, walking files - few easy ways.
Class finder - find classes on classpath.
Wildcard - using wildcards.
Servlets - various servlets-related tools.
Jodd tag library - new power to the JSP.
Form tag - automagically populates forms.
Class loading in Jodd - great ways for loading classes.
Fast buffers - really fast appendable storage.
Include-Exclude rules - small rule engine for filtering resources.

Jodd tools
Email - sending and receiving emails.
Props - enhanced Properties replacement.
HTTP - tiny, raw HTTP client.
Methref - strongly-typed method name references.
SwingSpy - inspection of swing component hierarchy.


05 agosto 2014

Web Article - Java 8 Stream

List myList =
    Arrays.asList("a1", "a2", "b1", "c2", "c1");

myList
    .stream()
    .filter(s -> s.startsWith("c"))
    .map(String::toUpperCase)
    .sorted()
    .forEach(System.out::println);

Full article: Java 8 Stream Tutorial

Stream Docs


31 julho 2014

Web Article - Logback Configuration Example

package com.javacodegeeks.examples.logbackexample.beans;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MarcoPoloBean {
 private static final Logger logger = LoggerFactory.getLogger(MarcoPoloBean.class);
 
 public void sayMarco() {
  String msg = "I'm Marco";
  
  logger.info("Hello there. I am {}", msg);
  
  logger.debug("Debugging message");
 }
}

22 julho 2014

InfoQ eMag: Java 8


Contents of the Java 8 eMag include:

  • Java 7 Features That Enable Java 8 - In this article, Ben Evans explores some features in Java 7 which laid the groundwork for the new features in Java 8.
  • How Functional Is Java 8? - It's been said that Java 8 is bringing Functional Programming to Java. By looking at the evolution of Java - particularly its type system, we can see how the new features of Java 8, especially lambda expressions, change the landscape, and provide some key benefits of the functional programming style.
  • Clarifying Lambdas in Java 8 - Simon Ritter discusses the syntax and use of Lambda expressions, focusing on using Streams to greatly simplify the way bulk and aggregate operations are handled in Java.
  • Intuitive, Robust Date and Time Handling Finally Comes to Java - Date and time are fundamental concepts to many applications, yet Java SE had no good API to handle them; until now! With Java SE 8, java.time provides a well-structured API to cover date and time. In this article, JSR-310 (Java Date and Time API's) spec-lead and Joda Time author Stephen Colbourne discusses the new API's as well as the background for Date and Time handling in Java 8.
  • Type Annotations in Java 8: Tools and Opportunities - With Java 8, annotations can be written not only on declarations, but on any use of a type such as types in declarations, generics, and casts. This article introduces the new type annotation syntax and practical tools to boost productivity and build higher-quality software.
  • Where Has the Java PermGen Gone? - Prior to JDK8 class metadata and constants would live in an area called the “permanent generation”, contiguous with the Java heap. One problem was that If the class metadata size is beyond the allocated bounds your app would run out of memory. With the advent of JDK8 we no longer have PermGen. The space where it was held has now moved to native memory to an area known as the “Metaspace”.
  • Nashorn: The Combined Power of Java and JavaScript in JDK 8 - With JDK 8, Nashorn replaces Rhino as Java’s standard JavaScript engine for the benefit of improved performance and compatibility. Avatar.js brings the popular Node framework’s programming model to Nashorn, enabling many JavaScript server applications to run in a Java environment. In this article JavaScript expert Oliver Zeigermann explains the hows and the why's.
  • Great Java 8 Features No One's Talking about - In this article Tal Weiss focuses on some lesser known API's in the new Java 8.

Web Article - JUnit Maven Example



21 julho 2014

Android - Remover pasta no File Explorer

Passos para apagar uma pasta no File Explorer

1 - Usando a linha de comandos (CMD) aceder a "platform-tools" do Android SDK
ex: C:\...\androidSdk\adt-bundle-windows-x86_64-20130917\sdk\platform-tools

2 - Executar o seguinte comando
#adb shell

3 - Entrar no sdcard
#cd sdcard

4 - Remover o directorio pretendido
#rm -r nomePasta





09 julho 2014

Largest collection of FREE Microsoft eBooks

Largest collection of FREE Microsoft eBooks ever, including: Windows 8.1, Windows 8, Windows 7, Office 2013, Office 365, Office 2010, SharePoint 2013, Dynamics CRM, PowerShell, Exchange Server, Lync 2013, System Center, Azure, Cloud, SQL Server, and much more.


Some books

image Migrate Roles and Features to Windows Server 2012 R2 or Windows Server 2012 PDF Source Contentimage
Introducing Microsoft SQL Server 2014 
PDF EPUB MOBI
image
Introducing Windows Server 2012 R2 
PDF EPUB MOBI
image
.NET Technology Guide for Business Applications 
PDF 


SQL Server 2012 Upgrade Technical Guide 
PDF EPUB MOBI


Backup and Restore of SQL Server Databases 
PDF EPUB MOBI

  SQL Server 2012 Tutorials: Analysis Services - Multidimensional Modeling PDF EPUB MOBI


Master Data Services Capacity Guidelines 
PDF EPUB MOBI



25 junho 2014

Web Article - 10 common mistakes Java developers make when writing SQL

1. Forgetting about NULL
2. Processing data in Java memory
3. Using UNION instead of UNION ALL
4. Using JDBC Paging to page large results
5. Joining data in Java memory
6. Using DISTINCT or UNION to remove duplicates from an accidental cartesian product
7. Not using the MERGE statement
8. Using aggregate functions instead of window functions
9. Using in-memory sorting for sort indirections
10. Inserting lots of records one by one

Full Article

20 maio 2014

Java - String Split with “.” (dot)

package com.lopes.tests;

public class StringSplitWithDot {

    public static void main(String[] args) {

        // Get only 12345
        String number = "12345.00000";

        // Split with error
        String splitError = number.split(".")[0];
        System.out.println("splitNumber " + splitError);

        // Correct way to split by dot(.)
        // "." is a special character. You have to use "\\." to escape this character
        String splitCorrect = number.split("\\.")[0];
        System.out.println("splitNumber " + splitCorrect);

    }

}


Output of Correct way
splitNumber 12345

JSF 2.2 New Features in Context

Now that JSF 2.2 is complete, this session demonstrates the most important features in the context of a self-contained sample application.

The features covered include
 • HTML5-friendly markup
• Faces Flow
• Resource library contracts

You will learn how JSF is still relevant in today's enterprise software stack. Specifically, you will learn why you would want to upgrade to JSF 2.2 rather than opting for a different architecture entirely.

23 abril 2014

Web Article - 10 JDK 7 Features to Revisit, Before You Welcome Java 8




1) Type inference2) String in Switch
3) Automatic Resource Management
4) Fork Join Framework
5) Underscore in Numeric literals
6) Catching Multiple Exception Type in Single Catch Block
7) Binary Literals with prefix "0b"
8) Java NIO 2.0
9) G1 Garbage Collector
10) More Precise Rethrowing of Exception

14 abril 2014

Web Article - Java ZIP File Example

In this tutorial see how to ZIP a file in Java.
ZIP is an archive file format that enables data compression and it is mostly used on files and folders. A ZIP file may contain one or more compressed files or folders. Many compression algorithms have been used by several ZIP implementations, which are ubiquitous in many platforms. It is also possible to store a file in a ZIP archive file without compressing it.


Source

21 março 2014

Designing Java EE Applications in the Age of CDI


"Even though CDI has been available since the end of 2009, most people still do not realize its full power and the possibilities it brings. Attend this session to understand which CDI features make it excel in comparison with other dependency-injection-based solutions and see how they can be used to design flexible applications and frameworks that will stand the test of time.

Copyright © 2013 Oracle and/or its affiliates. Oracle® is a registered trademark of Oracle and/or its affiliates. All rights reserved. Oracle disclaims any warranties or representations as to the accuracy or completeness of this recording, demonstration, and/or written materials (the "Materials"). The Materials are provided "as is" without any warranty of any kind, either express or implied, including without limitation warranties of merchantability, fitness for a particular purpose, and non-infringement."


Source: Oracle Learning Library

19 março 2014

Java SE 8 available




Highlights include the following (source)

Other links
Java 8 Released
Java 8 Tutorial
5 Features In Java 8 That WILL Change How You Code
What you need to know about Lambdas in Java 8
Java 8 Released! — Lambdas Tutorial
4 ways to celebrate the release of JDK 8
O mínimo que você deve saber de Java 8

01 março 2014

Code School - Learn by doing

Code School teaches web technologies in the comfort of your browser with video lessons, coding challenges, and screencasts.

Some courses:

27 fevereiro 2014

Maven - Standard Directory Layout

src/main/javaApplication/Library sources
src/main/resourcesApplication/Library resources
src/main/filtersResource filter files
src/main/assemblyAssembly descriptors
src/main/configConfiguration files
src/main/scriptsApplication/Library scripts
src/main/webappWeb application sources
src/test/javaTest sources
src/test/resourcesTest resources
src/test/filtersTest resource filter files
src/siteSite
LICENSE.txtProject's license
NOTICE.txtNotices and attributions required by libraries that the project depends on
README.txtProject's readme

More in Maven

20 fevereiro 2014

Web Article - Spring 3 and JPA with Hibernate

This article shows how to set up Spring with JPA, using Hibernate as a persistence provider.

The JPA Spring Configuration with Java
@Configuration
@EnableTransactionManagement
public class PersistenceJPAConfig{
 
   @Bean
   public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
      LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
      em.setDataSource(dataSource());
      em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" });
 
      JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
      em.setJpaVendorAdapter(vendorAdapter);
      em.setJpaProperties(additionalProperties());
 
      return em;
   }
 
   @Bean
   public DataSource dataSource(){
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName("com.mysql.jdbc.Driver");
      dataSource.setUrl("jdbc:mysql://localhost:3306/spring_jpa");
      dataSource.setUsername( "tutorialuser" );
      dataSource.setPassword( "tutorialmy5ql" );
      return dataSource;
   }
 
   @Bean
   public PlatformTransactionManager transactionManager(EntityManagerFactory emf){
      JpaTransactionManager transactionManager = new JpaTransactionManager();
      transactionManager.setEntityManagerFactory(emf);
 
      return transactionManager;
   }
 
   @Bean
   public PersistenceExceptionTranslationPostProcessor exceptionTranslation(){
      return new PersistenceExceptionTranslationPostProcessor();
   }
 
   Properties additionalProperties() {
      return new Properties() {
         {  // Hibernate Specific: 
            setProperty("hibernate.hbm2ddl.auto", "create-drop");
            setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
         }
      };
   }
}
The JPA Spring Configuration with XML

 
   
      
      
      
         
      
      
         
            create-drop
            org.hibernate.dialect.MySQL5Dialect
         
      
   
 
   
      
      
      
      
   
 
   
      
   
   
 
   
 

This Spring JPA Tutorial can be found in the github project – this is an Eclipse based project, so it should be easy to import and run as it is.
Source and full article in Baeldung.com


14 fevereiro 2014

13º Meeting PT.JUG

CDI/Deltaspike 
Jean-Louis Monteiro
Apache TomEE 
Jean-Louis Monteiro
More info in http://jug.pt/2014/02/11/meeting-13/

06 fevereiro 2014

Web Article - Fast, Effective, Double-Checked Locking in Android and Java Apps

public class Foo {
    private volatile Map< String, String > data;

    public Foo() { }

    public void setData(String key, String value) {
        if (data == null) {
            synchronized (this) {
                if (data == null)
                    data = new ConcurrentHashMap < String, String >();
            }
        }

        data.put(key, value);
    }
}

"There are two important things here. The first is adding the volatile modifier to the data field. This will instruct the compiler and eventually the Dalvik VM to ensure reads and writes are performed in a happened-before order (see here for more details). In other words, writes to the field always happen before reads (without this keyword, the compiler or JIT optimizer may decide to reverse them). Next, we add another null check for data outside the synchronized block. This will ensure once data has been allocated, we never synchronize again. However, if data is indeed null, we synchronize and then double-check if data is null just to make sure another thread hasn’t assigned a value between the two checks. If we lost the race, we’ll just continue normally and exit the synchronized block."

Source: Dzone

03 fevereiro 2014

Spring Framework 4 - A Guided Tour


About:
Spring Framework 4 builds the foundation for the next major generation of the Java application framework. The talk gives a practical overview about fundamental infrastructure improvements such as Java 8 support and the integration with the latest Java EE APIs. It also covers major enhancements all across the framework such as advanced support for Groovy, hypermedia aspects for REST web services as well as WebSockets support. Filmed at JAX London 2013.

More information in http://spring.io/

31 janeiro 2014

Java 8

Lambda expressions (closures) have been "coming" for quite some time, and they're finally "almost here". This talk describes the future directions for the Java language, especially the language and library changes coming in Java 8, from the perspective of "how did we get here?" and describing the approach taken for key language evolution choices.


Source: Evolving Java