JAVA_HOME and Alternatives on Linux

Usually when we install Java on Linux, we are "forced" to setup the JAVA_HOME variable.

And we usually perfom this task in this way:

sudo nano /etc/profile
adding this line:

export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-i386

And thats all!

But what about if we have more than one JVM installed on the system and depending on the project we switch the active JVM with "update-alternatives" or "galternatives" ?

So, if we have OpenJDK at JAVA_HOME variable, but our active JVM is another and we want all programs when using JAVA_HOME now use the active JVM, we will need to perform an update on "profile" specifying the new JVM path... again!

Doing that every time we switch between our installed JVM implementation.

I know, this is a pain in the ass.

But dont worry, we are on Linux and getting a solution for this kind or problem is very easy.

Just change that line with this one:

export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:bin/javac::")

This will assign JAVA_HOME the current path configured in the /user/bin/javac symbolic link.

So, we can now switch from JVM Alternatives without worry about JAVA_HOME value.


Importing/Migrating Subversion repository with all its revision history to Git - Bitbucket

So, after all, you've decided to take a chance on Git

But today, you're using Subversion,and you would like to migrate the repository with all its revision history to Git,including branches, comments and other.

How to do it?

First, if you use online services like Bitbucket, that provides Mercurial and Git hosting, you will find there an import mechanism for your Subversion repository, will be easy, but lacks on revision history import.

So you will have to perform an offline synchronization.

Let´s do it!

git svn clone -s http://mysubversionserver.com/myrespository
-s  param indicates that you subversion repository has the trunk/branches/tags structure and you want to keep it for importing. 

And thats all! You have now, a Git repository at myrepository folder with all your subversion revision history, branches and more.

But what about importing it to Bitbucket ?

2) Create your Git repository at Bitbucket and you will receive instructions there and how to link your local Git repository with Bitbucket.

2.1) Linking your local Git repository to a remote Git repository

git remote add origin

2.2) Push your local changes to a remote repository

git push -u --all origin  
Now, all local changes are pushed to the remote server with ORIGIN alias.

But wait! What about branches?

Subversion branches are created locally but without any direct relationship to a remote branch on ORIGIN.

Let´s make the relationship!

3) Wich one are my subversion branches ?

git branch -r

Will show those branches imported from subversion. 
Something like:


3.1) Now, we need Git to track changes on those branches for pushing it to remote repositories.

 git branch --track Branch1
 git branch --track Branch2
 git branch --track MyFuckingBoss

3.2) Push it to remote repository

git push -u --all origin  

And you will see something like:

 * [new branch]      Branch1 -> Branch1
 * [new branch]      Branch2 -> Branch2
 * [new branch]      MyFuckingBoss -> MyFuckingBoss

And finally, Thats all folks!!!!!

Creative Commons License This page is powered by Blogger. Isn't yours?