This is how you compile the jdk

Yeah – download the sources, install the required libraries, compile. Simple!

WHY would anyone want to do that?
Not entirely for the kicks, I must tell you. Or for the fact that it is open source and you can get your hands on the sources. Or for running your cpu at 150% and making it impossibly hot? Well if you are in search for drama – we can exchange laptops (Though I may be forced to get a replacement soon ūüėõ )!

I recently was on an ‘Advanced Concurrency’ training (No! I wasn’t the instructor) and that’s where I picked this idea of compiling the JDK (Wouldn’t it make a very good friend once you get to know him?). You can make some low level changes (Think: Go Deep! The JVM¬†level?). Our instructor did something very cool. He was trying to show us how modern JVMs, on runtime, do dynamic compilation and give massive performance boost. To show us that and for even much more (to look under the hood), he added his own code to the debug-jdk and from that marriage, something beautiful was born. He could map his source-code with the jvm-optimized-one.

JDK8 is required for the compilation process to begin so please get that first.

We’d be compiling JDK9 (which is still in Development).

# scm is done using hg - mercurial
$ sudo apt-get install mercurial
# tell hg your name
$ echo "[ui]" >> ~/.hgrc
$ echo "username=nikunjlahoti" >> ~/.hgrc

# clone the dev branch of jdk9 to a folder called 9dev
$ hg clone http://hg.openjdk.java.net/jdk9/dev 9dev
$ cd 9dev/
# Next execute the get_source.sh script to download everything in the forest
$ chmod u+x ./get_source.sh
$ sh ./get_source.sh
# this may take some time & bandwidth

# Reading the README would make things more clear. Do open the README-builds.html
$ cat README
# Configure the environment
$ bash ./configure
# Configure may fail when a particular dev library would not be present.
# It would tell you what to install to fix that issue. And run Configure again.
# Below is a list of libraries which were missing from my Ubuntu 14.04
$ sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev libcups2-dev libfreetype6-dev libasound2-dev

# Begin the compilation
$ make all

Build Statistics:
On my machine Linux 3.13.0-35-generic x86_64 x86_64 GNU/Linux it took around 40 minutes.

## Starting verify-modules
Checking dependencies across JDK modules
Access verification succeeded.
## Finished verify-modules (build time 00:00:59)

----- Build times -------
Start 2014-09-18 00:06:26
End   2014-09-18 00:46:02
00:00:59 verify-modules
00:39:36 TOTAL
-------------------------

Finished building OpenJDK for target ‘all’
Thu Sep 18 00:46:02 IST 2014

How to execute

$ cd 9dev/build/linux-x86_64-normal-server-release/jdk/bin
$ ./java -version
# openjdk version '1.9.0-internal'
# OpenJDK Runtime Environment (build 1.9.0-internal-nikunj_2014_09_18_00_01-b00)
# OpenJDK 64-Bit Server VM (build 1.9.0-internal-nikunj_2014_09_18_00_01-b00, mixed mode)

Separate logs for each order in Log4J

In my current project we are using Apache CommonsLogging backed up by Log4J.

Though it is a Multi-threaded application (processes multiple orders simultaneously), all the logs from all these threads simultaneously go inside a single file (via RollingFileAppender). Recently there was a change request to maintain separate logs for each order.
Having a separate file for every incoming order can prove a little more than costly.

— Housekeeping of these logs on the basis of time? Who decides which log has to be kept and which one has to be discarded? Perhaps it can be handled by writing a few shellscripts.

— Under development, or in production, for each run we’d have to open a different Log file to check the Logs for debugging purposes.

— On a Unix server there is a limited number of inodes or files that you can keep inside a directory. You run out of it then you cannot create more files and for such a bulky directory, manipulation would be a big pain.
So I would rather append an identifier (which can tell the order uniquely) with each and every log statement and then can easily `grep` the main Log file for the complete logs of a particular order.

— Appending ORDERID of that order to each and every log statement of a big big application would be a major overhead and isn’t maintainable. What if there comes a NEWUNIQUEVALUE for the orders!?

— Appending ORDERID just to the first and the last log statement wouldn’t guarantee that all the logs which get extracted are of that same order. It is a multi-threaded application anyway.

Step1:

Make changes to the Log4J.properties file. Add a %t at the starting of the Pattern.

Eg.

ConversionPattern=%p %c – %m%n

to

ConversionPattern=%t %p %c – %m%n

(Here we are asking the Logging Framework to append the name of the Thread to the logs)

t = Used to output the name of the thread that generated the logging event.

p = Used to output the priority of the logging event.

c = Used to output the category of the logging event.

m = Used to output the application supplied message associated with the logging event.

n = Outputs the platform dependent line separator character or characters.

Step2:

In your Java code, inside the run() method of the ThreadClass or the Concrete Implementation of the Runnable Interface change the name of the Thread using:


String uniqueOrderId = ${ fetched from inside the order XML etc };

Thread.currentThread().setName(uniqueOrderId);

If for some reason you need to preserve the ThreadName, in that case append it back to the uniqueOrderId.

Step3:

$ grep uniqueOrderId MAINLOG.log > uniqueOrderId.log

(find the lines with uniqueOrderId in the MAINLOG.log and create a new file uniqueOrderId.log with that)

COMPILE and EXECUTE!

(Dinner is getting cold. I know I could have been more verbose! TING!)

Taking SF.net out for a stroll

SourceForge.net (part of Geeknet, Inc.) is a web-based source code repository. It acts as a centralized location for software developers to control and manage open source software development. (source: Wikipedia)

(I plan to share my views and learning each day)

Day 0:

I am a member since 2008-06-19 01:05:49 PDT

(back in our college days our Wifi’d campus never allowed us to move past the registration page)

Thanks to this habit of mine, to register everywhere I see a signup page (not really!), all I had to do was to recover my account. Feels nice to have a userid without random or less-random and more unnecessary numbers attached to it. Tip: Register Early. I fear the day when parents would first check the availability of a decent GMail Id before giving their baby a name. [CREEPY] Ah! off track already.

Day 1:

My first (SUCCESSFUL attempt at creating an) opensource project. I named it FileRefresh (pretty lame. I know! But it looks good. Works Well)!

While checking the services tab in account link, I saw my favorite word – SSH (of course after Java).

SF.net lets you temporarily create a SHELL on their server to manage the data remotely using Putty or OpenSSH.

So I tried to connect using a terminal on my Ubuntu.

You may create a Public/Private key pair and save your Public Key in the SSH link.

SSH Public Key Upload

SSH Public Key Upload

// After one time passphrase authentication SSH wouldn’t ask me for my password now.

$ ssh mrdigerati@shell.sourceforge.net
Logging in to your interactive shell…
You don’t have an active shell at this time.
// no interactive shell was found.

// Lets create one

$ ssh -t mrdigerati,FileRefresh@shell.sourceforge.net create

Requesting a new shell for “mrdigerati” and exiting when it is ready.
queued… creating… starting…

// Login again

$ ssh mrdigerati@shell.sourceforge.net
Logging in to your interactive shell…
This is an interactive shell created for user mrdigerati,filerefresh.
Use the “timeleft” command to see how much time remains before shutdown.
Use the “shutdown” command to destroy the shell before the time limit.
For path information and login help, type “sf-help”.

// Logged in

[mrdigerati@shell-22005 ~]$ timeleft
Time remaining before shutdown: 239 minutes.

The Interactive Shell supports the following features:

  • SSH shell access to project content; access to data for other users and projects not provided
  • Comprehensive set to command line tools
  • 4 hour shell life – shells are automatically terminated after 4 hours. [True Story]
  • Password or SSH keys authentication
  • CVS repository administration

System info:

$ cat /etc/issue
CentOS release 5.6 (Final)
Kernel \r on an \m

$ uname -a
Linux shell-22005 2.6.18-238.19.1.el5.028stab092.2 #1 SMP Thu Jul 21 19:23:22 MSD 2011 x86_64 x86_64 x86_64 GNU/Linux

$ free
total       used       free     shared    buffers     cached
Mem:       1048576      41392    1007184          0          0          0

$ cat /proc/cpuinfo

Quadcore.

Intel(R) Xeon(R) CPU           E5345  @ 2.33GHz

commands which work:

links (console based browser)

zip unzip

wget

vi

/sbin/ifconfig

Tinkering around:

>> Send Real Emails (Do not SPAM).

$ mail -v -s “This is the subject” nikunjlahoti@email.com
This is a message.
.
Cc: nikunjlahoti@server.com

// -v : verbose and you get to see how the mails are delivered.

>> Ubuntu One Files >> Files.rename

// TODO

// Download on the file Server First. Zip/Change extension. FTP to your machine.

// This can let you store/download almost every file type (even those filtered by the proxy)

>> Setting up a Static Website

SFTP to /home/user-web/mrdigerati/htdocs/

CentOS 5.x Linux, running Apache 2.2.x

set your own pages. HTML/Perl/Python/Ruby/TCL/CGI/PHP

URL = http://mrdigerati.users.sourceforge.net/

(JSP (programming language) isn’t supported)

>> installing Java

// Java wasn’t installed by default

// Luckily we could download it from http://java.com/en/download/linux_manual.jsp on the server itself.

$ links http://java.com/en/download/linux_manual.jsp

// press enter on the download x64 button

$ unzip to <directory>

Set Environment Variables or use relative paths.

export PATH=$PATH:/bin

export JAVA_HOME=<directory>

>> Setting up Tomcat

// Downloaded from http://tomcat.apache.org/download-70.cgi

$ links http://tomcat.apache.org/download-70.cgi

// Download the Core Zip.

// Unzip and go inside. inside bin, do

$ chmod u+x *

$ ./startup.sh

$ ps -ef

(to check if Java Process is running)

tomcat7-installed

tomcat7-installed

>> Putty Export Display on Cygwin

// Couldn’t find any app of which display would be created. (absence of Firefox, Nautilus, Konqueror etc)

// I tried to download XClock but that needed ROOT permissions to be installed using `yum`.

>> So I tried a JAVA Swing program.

// Didn’t work either.

$ ./programs/jre1.6.0_29/bin/java HelloWorldFrame
Exception in thread “main” java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

// Setting display

$ export DISPLAY=localhost:10.0

$ ./programs/jre1.6.0_29/bin/java HelloWorldFrame

lib/amd64/xawt/libmawt.so: libXtst.so.6: cannot open shared object file: No such file or directory

// not finding xorg-x11-libs packages

>> Configuring Tomcat to work with Apache HTTP Server.

// Root access would again be required.

// TODO next day.

I must get some sleep now.

Conclusion:

SF.net can be used by beginners to enthusiasts to polish their Linux Skills (all they need is a Windows Computer + Putty + Internet)

http://newbiedoc.sourceforge.net/metadoc/sourceforge-guide.html

Upcoming:

Using repositories & Apps.

GIT, CVS, Mercurial, SVN.

Android: Contacts Storage

My Dear Andy,

Hope you are feeling better now.

I know it sucks to store all the email ids and display pictures of each and every individual I ever emailed thru my gmail account.

People who I don’t even speak to anymore and even Dead People X-|

Okay.. so the letter writing idea was lame. Lets just stick to business.

Premise:

So the size of the Contacts Storage for me was 13.76Mb (with Facebook contacts sync’d as well). 2047 (Useless+Very Useful) Contacts.

Anyway, I figured that only 900 of these Contacts actually have phone numbers.

Because my Motorola Milestone suffer from real RAM issues (just 256Mbs of it and at any given point of time no more than 30Mbs Free).

Yeah Yeah.. i know i Know … My bad!! I should not put all the applications from the market inside it… but that’s what it is meant for right?

I spend 22K for nothing? So because of the Huge size of Contacts Storage the free memory would be less and applications would get Garbage Collected more often :-/ Leaving me ūüė¶ and X-(

Research:

So I began to search for ways so that I can reduce the size of the display image each contact has.

Or some way to just sync contacts with Phone numbers. I couldn’t find anything useful.

Even if I use …

a) Display options to show just the contacts with phone numbers

b) sync just one of the categories of contacts (like “My Contacts” or “Family”)

…. the contact storage would remain the same size.

Work Around:

I exported all 2000+ contacts to SDCard (using the ImportExport option in the contacts).

It saved the exported VCard File as “00001.vcf”.

I saved it on my desktop and I wrote a quick Java Program to Read the VCards one by one from a file.

Look inside if it contains a TELEPHONE number. If Yes then save it to the “output.vcf” file.

Help Contacts Storage

HelpContactsStorage to find relevant contacts!

Usage:

$ java -jar HelpContactsStorage.jar

Or

$ java -jar HelpContactsStorage.jar 00001.vcf

Or

$ java -jar HelpContactsStorage.jar inputFile.vcf finalFile.vcf

Download the Source Code from here. Download sample vcf here.

Later:

a) Disable the contacts sync with Google or Facebook.

b) Go to the Display options & Select to show all contacts.

c) place output.vcf on the SDCard.

d) Go to Applications –> All –> Contacts Storage. And Clear Data.

e) Go to contacts, import contacts from the SD Card. Select “output.vcf”

f) Keep the Sync Off.

Prost! ūüôā

Original Size: 13Mb

Final Size: 3.5Mb!