How to encrypt/decrypt files in Java with AES in CBC mode using Bouncy Castle API and NetBeans or Eclipse

The Bouncy Castle Crypto API for Java provides a lightweight cryptography API that is an alternative to the standard Sun Java Cryptographic Architecture (JCA) and Java Cryptographic Extension (JCE) bundled in the JDK. The API can be used in J2ME MIDlet applications or in other Java applications. The Bouncy Castle lightweight cryptographic API can be […]

Read More →
How to convert a byte array to a Hex String in Java

When processing binary values it is very difficult to read or to display them because any printing function generates a String value.  The problem with this approach is that not all byte values can be interpreted as a printable char (i.e. the 0 binary value represents the NUL symbol; for more details check ASCII Codes […]

Read More →
Tutorial Java SCJP – #19 Enumerated lists or Enums

There are logically situations in which a variable must have values restricted to a specific range or set that is defined in the solution specifications. Let’s imagine that you must develop a Java applications that manages Vehicles and the engine type must take one value from the {GASOLINE, DIESEL, HYBRID, ELECTRICAL} set. You can define […]

Read More →
Tutorial Java SCJP – #18 Initialization blocks

In order to process something you need values. And values are usually stored in static variables, local variables (defined in methods) or instance variables (nonstatic variables defined in classes). In order to initialize a variable you can do it at definition or later in a method (constructor or not). Despite these two common solutions, there […]

Read More →
Tutorial Java SCJP – #17 Access modifiers for methods and attributes

Access modifiers represents ways to give or to restrict access to class variables and methods. One reason is the encapsulation concept that states that instance variables are not accessed directly, but only through access methods (prefixed with get or set). Another reason is to control how the class is used and how and what values […]

Read More →
How to parse XML, RSS feed with kXML in a J2ME MIDlet

More an more mobile devices are used to access Internet and connected services. One efficient way to transfer data between different platforms and technologies is to use XML files, which are simple text files formatted accordingly to the XML rules. IN order to process an XML file and to extract needed data you need a […]

Read More →
Tutorial Java SCJP – #16 Constructors

In a class you can define methods, but there is a special type of methods which are used to solve a particular problem, to construct objects. Constructor methods are special because of their role and because they have a lot rules regarding declaration and usage.

Read More →
Tutorial Java SCJP – #15 Wrapper classes for primitive types

In Java there are 2 important categories of data types: references and primitives. Most of the time, numeric values, chars and boolean values are used as primitives because it is more efficient as processing speed and memory requirements. Despite that, there are scenarios (like using Collections) when it is needed to store primitive values inside […]

Read More →
Tutorial Java SCJP – #14 Methods and passing variables into methods

In Java, methods define the object behavior or implement different functionalities at class level (for static methods). If variables (value type or references) represent the static part of Java programming,then methods represent the dynamic part because methods are equivalent to code blocks that are executed and that are processing some variables.

Read More →
Tutorial Java SCJP – #13 Packages and Class access modifiers

Two important concept of Object Oriented Programming is to separate entities based on their functionality or logic and to hide data and behavior within a class (encapsulation). For that you have classes used to define entities that have attributes and a behavior (their methods). At a higher level, for a good organization of the application […]

Read More →
Tutorial Java SCJP – #12 Immutable, String and Integer

Immutable objects are objects that don’t change their value once they are created. The most known immutable object in Java is String. Besides String, there is another immutable object, and this is Integer (the class and not the primitive) which has an interesting behavior for values between -128 and 127 .

Read More →
Tutorial Java SCJP – #10 Variable Scope

Many compiler errors are generated because programmers don’t have a clear image on how long variables are available and when they can access them. The variable scope concept  describes the life of a variable, or its availability area, after it was defined.

Read More →
Tutorial Java – #9 Garbage collection and memory leaks

Since the first days of computer programs, one important performance issue was the and still is the amount of used memory. Despite the fact that today the hardware technology provide large amounts of Random Access Memory, software developers must pay attention to how they manage the application memory because they can implement wrong solutions that […]

Read More →
Tutorial Java – #8 Understand Stack and Heap

In order to have a deep understanding of the Object Oriented Programming in Java or any other OOP language (like C#) you must know how things are managed internally by the Java process and by the JVM. Of course Java syntax and Java implementations of OOP principles are important but you will have a more […]

Read More →
Tutorial Java – #7 Reference data type variables

In this post it is described one of the most important concepts of Object Oriented Programming: Every class instance, object, is managed only by reference type variables (for those who know also C++, you could remember that in C++ this rule is not entirely true because objects are also managed by value type variables). This […]

Read More →
Tutorial Java – #6 Classes and objects

Classes represent the basic principles of object-oriented programming. Classes are abstract concepts, stories, blueprints, describing: characteristics, attributes of an object; these represent what the object knows, what it is; object methods; these represent what the object knows to do, its behavior; Based on classes, the programmer can define something concrete, objects. Thus, by instantiating the […]

Read More →