Mostrar mensagens com a etiqueta Article. Mostrar todas as mensagens
Mostrar mensagens com a etiqueta Article. Mostrar todas as mensagens

06 fevereiro 2017

Web Article - Angular CLI


Initially, the entry barrier into the world of Angular development was pretty high because of the need to learn and manually configure multiple tools. Even to get started with a simple application, you’d need to learn the TypeScript language (an easy job for Java developers), learn how to configure and use the TypeScript compiler, ES6 modules, a module loader (e.g. SystemJS), test runners, npm, a dev web server. To work on a real-world project, you’d also need to learn how to test and bundle your app for deployment.

cli




20 abril 2016

Web Article - JAX-RS Annotations Explained

JAX-RS Annotations
1.1. @Path
1.2. @PathParam
1.3. @GET
1.4. @POST
1.5. @PUT
1.6. @DELETE
1.7. @Consumes
1.8. @Produces
1.9. @QueryParam



Full Article here

17 outubro 2015

Web Article - Spring JMS Example

Java Messaging Service (JMS) is a standard messaging API used to send and receive messages.

Spring simplifies the use of JMS API by providing another layer around the JMS layer.

This layer provides convenience methods for sending and receiving messages, as well as manages the creation and release of resources like the connection object.

The JmsTemplate class is the main class which we will be using often to work with the JMS API.

Dependencies

 4.0.0
 com.javacodegeeks.camel
 springQuartzScheduler
 0.0.1-SNAPSHOT
 
  
   org.springframework
   spring-core
   4.1.5.RELEASE
  
  
   org.springframework
   spring-context
   4.1.5.RELEASE
  
  
   org.springframework
   spring-jms
   4.1.5.RELEASE
  
  
   org.apache.activemq
   activemq-all
   5.12.0
  
 
 

Read full atricle here.

20 setembro 2015

Web Article - Android: Boost up the Android emulator speed up to 400% on Intel based architecture

Okay, it is slow. Then what can we do about it?

Let us go through steps to solve the slowness problem of Android emulator;
  1. First, let us delegate the rendering process to host GPU instead of overhead our CPU by this process, it will make it happy. Do it by checking "Use Host GPU" checkbox in AVD’s edit window.
    The screen should now look better and be more responsive. That is because the CPU is happy to not dealing with the tedious work of doing rendering anymore. However, that is still not fast enough.
    a2
  2. Second we need to download Intel Atom (x86) system image for each Android version you need to use for testing.
    a3
  3. Third, download Intel x86 Emulator Accelerator (HAXM, for Mac and Windows only). This will enable virtual machine acceleration capabilities of the Intel CPU, from Android SDK manager –> tools. Or install it from Intel site.
    a4
  4. The SDK only copies the Intel HAXM executable on your machine, and it is up to you to install the executable.
    To install the Intel HAXM executable, search your hard drive for IntelHaxm.exe (or IntelHAXM.dmg on Mac OS X). If you left everything to default, it should be located at%Android_HOME%\sdk\extras\Intel\Hardware_Accelerated_Execution_Manager\IntelHaxm.exe.
    Intel HAXM only works in combination with one of the Intel® Atom™ processor x86 system images.
    a5
  5. In order to be able to install the Intel HAXM, you need to have Intel VT-x enabled in your BIOS, otherwise you will get an error like this during install.
    a5b

    Enabling Intel VT (Virtualization Technology)
    a6

    How do I enable Intel VT in your machine BIOS?
    1. Boot into BIOS.
    2. Select "Config".
    3. Select "CPU".
    4. Press enter at "Intel Virtualization Technology".
    5. Select "Disable".
    6. Press F10 and select Yes.
    7. Boot into Windows then shutdown the system.
    8. Boot into BIOS again.
    9. Select "Enable" – Intel Virtualization Technology.
    10. Press F10 and select Yes.
  6. After installation goes successful, edit your AVD and chose Intel® Atom (x86).
    a8
  7. Finally Hit okay, then lunch your cake and definitely enjoy the speed.
VIP Note:
You could say that this level of speed should be sufficient. That may be true, but an issue with the Intel x86 images is that you do not get Google Apps, they only come with ARM images. This is important if you are testing an app that usesGMaps, or Google Play Services.

Source: javacodegeeks.com

14 abril 2015

Web Article - JDBC Batch Update Example




Approach 1: Jdbc Batch Update using Statement object


Approach 2: Jdbc Batch Update using PreparedStatement
Source: javacodegeeks.com

21 janeiro 2015

Web Article - Quartz HelloWorld Example

pom.xml:

 4.0.0
 com.javacodegeeks.snippets.enterprise
 quartzexample
 0.0.1-SNAPSHOT

 
  
   org.quartz-scheduler
   quartz
   2.2.1
  
 


MyApp.java
package com.javacodegeeks.snippets.enterprise.quartzexample;

import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

import com.javacodegeeks.snippets.enterprise.quartzexample.job.ByeJob;
import com.javacodegeeks.snippets.enterprise.quartzexample.job.HelloJob;

public class MyApp {

 public static void main(String[] args) {
  try {
   JobDetail job1 = JobBuilder.newJob(HelloJob.class).withIdentity("helloJob", "group1").build();

   Trigger trigger1 = TriggerBuilder.newTrigger().withIdentity("simpleTrigger", "group1")
     .withSchedule(SimpleScheduleBuilder.repeatSecondlyForTotalCount(30)).build();   
   Scheduler scheduler1 = new StdSchedulerFactory().getScheduler(); 
   scheduler1.start(); 
   scheduler1.scheduleJob(job1, trigger1); 
   
   JobDetail job2 = JobBuilder.newJob(ByeJob.class).withIdentity("byeJob", "group2").build();
   Trigger trigger2 = TriggerBuilder.newTrigger().withIdentity("cronTrigger", "group2")
     .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?")).build();
   Scheduler scheduler2 = new StdSchedulerFactory().getScheduler();
   scheduler2.start(); 
   scheduler2.scheduleJob(job2, trigger2); 
   }
  catch(Exception e){ 
   e.printStackTrace();
  }
 }

}

Source: javacodegeeks

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

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


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

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

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


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

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

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

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.