Posts

Best way to send an email using Java

Which email type should I send: Html or Plain text , why? Well, html is nicer (and links are clickable, and font could be bolded etc) but may cause more problems because some email clients might not be able to read it, not to mention smartphones or other devices which might prefer plain text emails. My suggestion is to send two emails, an html one and a plain text one - bundled together (multipart email) and let the email client decide which it wants to read. But we still have some hurdles: Not all email clients read CSS Some firewalls might block html Some firewalls might block images. So what should I do? - I think the best option is to eliminate as much obstacles as necessary in the html version of the email, and then send it bundled with a plain text email which should cover all cases. So lets by eliminating obstacles. CSS can't be read by many email clients? - Don't use CSS in your emails. HTML isn't supported? Bundle a plain text email ...

2014 Logging Frameworks You Would Like to Work With

In my previous post I have given an overview about Java's logging state as of January 2014 In this post I want to recommend which libraries to use for your java project. Main Logging Frameworks Most notable frameworks in this section include:  Java Util Logging ,  Log4j ,  Logback ,  Log4j2 I will go over them one by one: Java Util Logging  - This is Java's official logging framework it has been there since 2002 and is mostly copied from log4j which have released their library two years before (2000). no significant updates have been released to the Java logging component and it is mostly abandoned (although it still resides in the rt.jar core java files), the brave developers who had tried using it report a complicated logging framework which needs a good overhaul and the general advice is to stay away from it! Log4j  - No need to introduce Log4j which is the most used logging framework, and is with us for over 14 years!, log4j is a ve...

2014 Overview of Logging in Java

Why do you even need a logging framework [In a nutshell] ? Logging severity (Debug / Info / Error etc) Different loggers for different tasks Logging configuration in a single XML instead of all over your application Lots of other reasons Sorry, it is so obvious to me that I can't elaborate here any further What sorts of logging components are there ? Main Logging frameworks (use these to do the actual logging [log4j, logback etc]) Logging APIs (Facade): Due to several different logging frameworks, a need for a unified API has risen, and of course now there are several different "unified" APIs. Logging Parsers : Components which enable us to read log streams (files, socket etc) conveniently as well as introduce advanced searching & filtering within the log files Main Logging Frameworks The main logging frameworks is what people usually refer to when talking about in app logging, and I suggest a rough division in this department: Robust ...

Best Lossless Image Size Reduction Freewares

Lossless image reduction means reducing a given image's size without losing quality at all! This should be done by default, the truth is that we shouldn't have external tools to reduce size without losing anything because the current software we use to create the original images should apply lossless image reduction techniques - it is lossless so no quality is lost what so ever! Anyway, we live in a non perfect world, so we need these tools. In my post i want to write about the best tools for this task. Requirements: 1. Lossless image size reduction. 2. Support for all file formats (at least png, gif & jpg). 3. Easy to use user interface . 4. Option to be recursive = option to submit to the tool a directory and it will convert all of the images it contains (and all of the images contained in any sub directory etc) 5. Option to overwrite original images. 6. Free After lots of googling around I found the following as the best tools to use,...

The best way to join Strings in Java

Joining strings in java is quite simple, just take two strings and add them using the "+" sign as follows: String s = "One" + " Two"; Which results in: s == "One Two". The thing is that String objects in Java are immutable, so you can't actually change any string, which means that in the following example: String a = "One"; String x = a; in memory now: (a == x) a = a + " Two";  Will result in the following in-memory statement:  ( a != x ) which is a reason for many many bugs in many programs. Another side effect of immutable objects is that every "change" of the string will actually create a new one, resulting in lots of dead objects which will later on be ditched by the garabage collector, but in the meanwhile they consume memory, and will use CPU to collect them. StringBuilder / StringBuffer The simplest solution supplied by Java is using StringBuilder / StringBuffer (Strin...

Launch the perfect set of hundreds of offline free games with a launcher in under 5 minutes

If you want to play good games, but don't want to play online games, and don't want to waste your time for searching games one after the other till you find a decent and free good game then just read this post and I will guide you to the perfect and effortless set of free games you can obtain in 5 minutes. These games will fit any person with the following requirements from his games: Only free games Don't care about graphics (So if a game has good playability you want to play it even if it is 20 years old) Hundreds of games to pick from Obtain them in 5 minutes Have a nice launcher where each game will have a picture and you only need to click the picture to play the game The answer is simple my friend, you are looking for a good console games emulator with a beautiful launcher. Emulators, emulate a specific gaming machine so, for example, you can download a Nintendo (NES) emulator and play all of the Nintendo original games. But still you will nee...

Tools for Wickets Development with IntelliJ's Idea

One of Java's most popular web frameworks is Wicket. If you want to start developing Wickets let me guide you through the installation of 2 plugins which will make your development much more productive. I will write the steps to install these plugins, but I will write them in a short way, if you want a more detailed guide please refer to this page: Installing Wicket Source 1. IntelliJ --> Settings --> Plugins --> Browse Repositories --> Search for "Wicket" --> Install Wicket Forge & Wicket Source. 2. Restart IntelliJ 2.5. You have installed the 2 plugins and you are set to go (the next steps are highly recommended but optional) - WicketForge lets IntelliJ understand Wicket (you can now start a new Wicket file etc), WicketSource lets IntelliJ understand the html wicket ids, which means that you can click on a wicket:id and jump to it's definition in the code / html. The following steps are optional and will enable your browser to ...