GIT vs SVN

Submitted by Jochus on Wed, 06/02/2013 - 20:56 | Posted in: Java
Posted in


There are many comparison lists to find on the web, but this is one I've created after I tested GIT. I have a lot of experience with Subversion, but I was wondering what the power/advantages of GIT are.

What is GIT?

GIT is a free distributed revision control, or software source code management project with an emphasis on being fast. GIT was initially created by Linus Torvalds for Linux kernel development.

Every GIT working directory is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.

Several high-profile software projects now use GIT for revision control, most notably the Linux kernel, Perl, Samba, X.org Server, Qt (toolkit), One Laptop per Child (OLPC) core development[5], Ruby on Rails web framework, VLC, Merb, Wine, SWI Prolog, DragonFly BSD and the Android mobile platform.

Pro's

  • distributed: you are no longer dependent on 1 server. You can also retrieve data from your "neighbours" which have also checked out some code of a server. The retrieval of this data is called a pull operation; the sending of data to your neighbours (also called remotes), is called a push operation
  • .git folder: in contrast of Subversion in which each folder has a .svn directory, GIT will only create 1 .git folder. In this folder, each file/folder which is changed/added/deleted/renamed/ ... gets tracked. This .git folder is basicly an index in which files/folders can be quickly retrieved
  • DAG all data gets stored as a DAG (Directed Cyclic Graph). SVN uses a tree architecture. The use of a DAG gives GIT the possibility to create branches from different "trees". Different knots can point to different branches
  • GUI tools: if you don't like the commandline to use GIT, you can use of the many GUI tools like TortoiseGIT to keep track of changes in your directory in a graphical way
  • Merging: the way GIT thinks about merging is more flexible than SVN. For example: you can merge little parts of files to another branch, and leave the other changes in the file in your working copy. This is called: committing a hunk
  • changes: the changes to a tree can easily be e-mailed to other persons
  • history: asking for the history of file/folder in GIT is so much faster than SVN as you don't need a central server to ask for history. All history is stored in an index file
  • goal: GIT is very useful for open source projects: contributors can simply make patches, branch, merge branches of various contributors, all independent on the master server

Cons

  • distributed: it seems to be an advantage to move from a centralized to a distributed system, yet, it seems weird that you can retrieve data from the neighbours as well (and not only from a central repository). For me, this is something really strange. Imagine each developer has its own GIT local repository. If you want to update your local repository, you have to fetch the updates from all of the developers? Or do you still need a central repository? But then I need to commit AND and I need to push the changes to the central repository. That's 1 extra operation compared with SVN
  • high learning curve: a wide variety of commands can make this tool very complex. If you want to introduce GIT in your team, I really think you should have at least one developer which has advanced knowledge/experience of GIT. Or each of the developers needs to be for 100% committed to use this new version control system. Otherwise, people will be quickly annoyed.

JDeveloper 11g and Maven

Submitted by Jochus on Thu, 03/01/2013 - 21:06 | Posted in: Java
Posted in



This evening, I played a little bit with Oracle JDeveloper 11g (http://www.oracle.com/technetwork/developer-tools/jdev/overview/index.h…). I'm using Eclipse since 2007 as IDE and I'm very happy with it, but I was wondering how JDeveloper works.

I wanted to import some existing Java projects into my JDeveloper workspace. I'm used to run the $ mvn eclipse:eclipse command to create a .project and .classpath file, but I noticed there's no $ mvn jdeveloper:jdeveloper command. However, after Googling, I found that Trinidad developed a custom plugin which does exactly the same.

To let it work, add the following tag in the pom.xml file:

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.myfaces.trinidadbuild</groupId>
        <artifactId>maven-jdev-plugin</artifactId>
      </plugin>
    </plugins>
</build>

Then, run the following command:

$ mvn jdev:jdev

This command will create a JDeveloper .jpr project file which you can easily import in JDeveloper.

Deploying to JBoss AS 6.X through Maven

Submitted by Jochus on Wed, 02/01/2013 - 23:40 | Posted in: Java
Posted in


In your POM file, add the following plugin:

<plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>jboss-maven-plugin</artifactId>
     <version>1.5.0</version>
     <configuration>
         <jbossHome>${jbossHome}</jbossHome>
         <port>${jbossPort}</port>
         <serverName>${jbossServerName}</serverName>
         <fileName>target/my-webapp.war</fileName>
     </configuration>
</plugin>

In your settings.xml file (which is user dependent), add the following properties:

           ...
           <profile>
               <id>inject-application-home</id>
               <properties>
                   <jbossHome>/Applications/jboss-6.1.0.Final/</jbossHome>
                   <jbossPort>8080</jbossPort>
                   <jbossServerName>default</jbossServerName>
               </properties>
           </profile>
       </profiles>
       <activeProfiles>
           <activeProfile>inject-application-home</activeProfile>
       </activeProfiles>

To deploy, you can execute the command:

$ mvn jboss:hard-deploy
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building my-webapp Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- jboss-maven-plugin:1.5.0:hard-deploy (default-cli) @ my-webapp ---
[INFO] Copying /Users/jochen/Documents/workspace/TestDeployWebapp/my-webapp/target/my-webapp.war to /Applications/jboss-6.1.0.Final/server/default/deploy/my-webapp.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.498s
[INFO] Finished at: Wed Jan 02 11:32:48 CET 2013
[INFO] Final Memory: 3M/81M
[INFO] ------------------------------------------------------------------------

Touchpad freezes on Medion MD96500

Submitted by Jochus on Mon, 31/12/2012 - 14:03 | Posted in: Windows
Posted in




Today, I had to fix a very old Medion laptop of a friend on which the touchpad stopped working after a while working on the laptop. After booting, the touchpad could be used for +- 5 minutes, but afterwards the only way to move the mouse pointer was by attaching an external USB mouse.

I fixed the issue by installing the following driver: http://www1.medion.de/downloads/download.pl?id=3031&type=treiber&filena…. After a reboot, the touchpad kept working.

Creating a custom JSF deployer in JBoss AS 6.X

Submitted by Jochus on Sun, 30/12/2012 - 18:47 | Posted in: Java
Posted in

JBoss AS 6.X gets shipped with Mojarra 2.0.3 (b5), but I wanted to do some testing with Mojarra 2.0.9. To be able to use this JSF implementation, you need to create a custom JSF deployer:

~ $ cd /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer $ mkdir Mojarra-2.0.9
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer $ cd Mojarra-2.0.9/
/Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/Mojarra-2.0.9 $ mkdir META-INF jsf-libs

In the META-INF folder, create the following file: web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="<a href="http://java.sun.com/xml/ns/javaee"&#10">http://java.sun.com/xml/ns/javaee"&#10</a>;   xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance"&#10">http://www.w3.org/2001/XMLSchema-instance"&#10</a>;   xsi:schemaLocation="<a href="http://java.sun.com/xml/ns/javaee">http://java.sun.com/xml/ns/javaee</a> <a href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&#10">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&#10</a>;   version="2.5">
   <!-- ======================== Introduction ============================== -->
   <!-- This document defines default values for the Mojarra-2.0 JSF config  -->
   <!--                                                                      -->
   <!-- WARNING:  Do not configure application-specific resources here!      -->
   <!-- They should go in the "/WEB-INF/web.xml" file in your application.   -->
 
   <!-- =========== Common Context Params ================================== -->
 
   <!-- Regular expression to determine if two different URLs actually point -->
   <!-- to the same jar file.  This keeps faces-config files from being      -->
   <!-- read twice.                                                          -->
   <context-param>
     <param-name>com.sun.faces.duplicateJARPattern</param-name>
     <param-value>^tmp\d+(\S*\.jar)</param-value>
   </context-param>
 
   <!-- JBossInjectionProvider provides resource injection for managed beans. -->
   <!-- See JSF 1.2 spec section 5.4 for details.                             -->
   <context-param>
     <param-name>com.sun.faces.injectionProvider</param-name>
     <param-value>org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider</param-value>
   </context-param>
 
   <!-- ================== Common filter Configuration ==================== -->
 
 
   <!-- ================== Common Listener Configuration ==================== -->
   <!-- Configures JSF 2.0 -->
   <listener>
     <listener-class>org.jboss.web.jsf.integration.config.JBossMojarra20ConfigureListener</listener-class>
   </listener>
 
</web-app>

In jsf-libs:

  • Copy the file jboss-faces.jar from the 2.0.3 folder
  • Download the JSF libraries from: http://javaserverfaces.java.net/download.html
  • This should result in something as:
    /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/Mojarra-2.0.9/jsf-libs $ ls -al
    total 4952
    drwxr-xr-x  5 jochen  staff      170 Nov  7 16:58 .
    drwxr-xr-x  4 jochen  staff      136 Nov  7 16:44 ..
    -rw-r--r--@ 1 jochen  staff     6148 Nov  7 16:58 .DS_Store
    -rw-r--r--@ 1 jochen  staff  2502592 Nov  7 16:45 javax.faces-2.0.9.jar
    -rw-rw-r--@ 1 jochen  staff    21804 Aug 16  2011 jboss-faces.jar



Open the file: /Applications/jboss-6.1.0.Final/server/default/deployers/jsf.deployer/META-INF/jsf-integration-deployer-jboss-beans.xml:

  • Extend the property jsfConfigurations:
        <property name="jsfConfigurations">
          <map keyClass="java.lang.String" valueClass="java.lang.String">
            ...
            <entry>
              <key>Mojarra-2.0.9</key>
              <value>${jboss.server.home.url}deployers/jsf.deployer/Mojarra-2.0.9</value>
            </entry>
            ...
          </map>
        </property>
  • Add the following bean:
      ...
      <bean name="JSFUrlIntegrationDeployer-209" class="org.jboss.jsf.deployer.JSFUrlIntegrationDeployer">
        <property name="JSFConfigName">
          <value>Mojarra-2.0.9</value>
        </property>
        <property name="JSFImplManagementDeployer">
          <inject bean="JSFImplManagementDeployer"/>
        </property>
      </bean>
      ...



Finally, to let your web application use the correct JSF deployer, make a reference in your WEB-INF/web.xml of your application (using the context-param: org.jboss.jbossfaces.JSF_CONFIG_NAME) :

	<context-param>
		<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
		<param-value>Mojarra-2.0.9</param-value>
	</context-param>

Enabling syntax highlighting in vim

Submitted by Jochus on Thu, 27/12/2012 - 22:24 | Posted in: Mac
Posted in


$ cd /usr/share/vim
$ sudo vim vimrc

Add the following lines below: set backspace=2

set ai                  " auto indenting
set history=100         " keep 100 lines of history
set ruler               " show the cursor position
syntax on               " syntax highlighting
set hlsearch            " highlight the last searched term
filetype plugin on      " use the file type plugins
 
" When editing a file, always jump to the last cursor position
autocmd BufReadPost *
\ if ! exists("g:leave_my_cursor_position_alone") |
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
\ endif

Creating a Java heapdump in JBoss AS 6.x

Submitted by Jochus on Wed, 12/12/2012 - 23:12 | Posted in: Java
Posted in


If you want to create a heapdump from your application running in a JBoss AS 6.X J2EE container, you can easily perform the dump operation by some MBean in the JMX console.

  • Browse to: http://localhost:8080/jmx-console/
  • Search for com.sun.management and click on type=HotSpotDiagnostic
  • Scroll to the bottom of the page and provide the parameter /tmp/heap.dump in the textfield p0, which is actually the location to which the dump will be written. If you want to perform a garbage collection before dumping, leave p1 on value true
  • Push the button Invoke. A dump file will be available at /tmp/heap.dump. This file can easily be viewed by a tool like Java VisualVM



Also, remember that you can easily create a heap dump automatically when JBoss is going OutOfMemory. Just add the following Java arguments in your run.conf file

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp/heap.dump

How to re-enable the Apple-provided Java SE 6 applet plug-in

Submitted by Jochus on Mon, 10/12/2012 - 15:08 | Posted in: Mac
Posted in


After the latest Java update on Mac OS X 10.7, I was unable to use the Java plugin in my Chrome browser (I'm not really into Java applets, but the Java applet in JIRA to attach screenshots is very easy and useful to use in combination with Cmd + Shift + 4 buttons).

To fix this issue, follow the steps written below:

  • Open Terminal, located in the Utilities folder.
  • Enter this command, then press the Return or Enter key:
    $ sudo mkdir -p /Library/Internet\ Plug-Ins/disabled
  • Enter this command, then press the Return or Enter key:
    $ sudo mv /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin /Library/Internet\ Plug-Ins/disabled
  • Enter this command, then press the Return or Enter key:
    $ sudo ln -sf /System/Library/Java/Support/Deploy.bundle/Contents/Resources/JavaPlugin2_NPAPI.plug



Source: http://support.apple.com/kb/HT5559

FCCU virus verwijderen

Submitted by Jochus on Sat, 08/12/2012 - 19:29 | Posted in: Windows
Posted in


Gisterenavond bij iemand langs geweest omdat die het bovenstaande scherm kreeg. De PC zit volledig blok, je kan nergens meer naar toe. Zelfs via "Veilige modus" lukte het niet meer.

Hardnekkig virus/malware, maar ik heb het er op deze manier afgekregen:

  • Download Windows Offline Defender en maak een startup cd/dvd of usb stick
  • Start daarna de pc op met de Windows Offline Defender disk
  • Scan u computer op malware met de Windows Offline Defender software
  • Herstart uw PC en kies voor een normale startup. Het virus zal nu niet meer opkomen, maar het is wel nog steeds aanwezig op de PC
  • Scan daarna u computer met MalwareBytes AntiMalware om het FCCU virus te verwijderen of te detecteren
  • Scan nogmaals met ComboFix! om deze malware nog dieper te detecteren en te verwijderen

Windows Offline Defender en MalwareBytes hebben er voor gezorgd dat de PC terug "vrij" kwam.
De ComboFix! heeft de "Veilig modus" terug hersteld.

... geef mij toch Mac OS X :-) ...