Blog Archives

XPath cheats

Get the child element nodes of a book node (without comment nodes and text nodes)

//book/*

Get the child elements, text and comment nodes of a book node

//book/*|text()|comment()

The following XPath queries return the same nodes:

$xpath->query("./../bookstore", $contextNode)
$xpath->query("../bookstore", $contextNode);

Java Class Versions

  • Java 1.1 uses major version 45
  • Java 1.2 uses major version 46
  • Java 1.3 uses major version 47
  • Java 1.4 uses major version 48
  • Java 5 uses major version 49
  • Java 6 uses major version 50
  • Java 7 uses major version 51
  • Java 8 uses major version 52
  • Java 9 uses major version 53
  • Java 10 uses major version 54
  • Java 11 uses major version 55
  • Java 12 uses major version 56
  • Java 13 uses major version 57
  • Java 14 uses major version 58

Extract the Java version of a .class file

Every Java Class file has been compiled with a specific Java version. To get the version try:

/path/to/jdk/bin/javap -verbose ClassFile | grep "version:"

Here is the list of all currently known Java versions:


    Java 1.2 uses major version 46
    Java 1.3 uses major version 47
    Java 1.4 uses major version 48
    Java 5 uses major version 49
    Java 6 uses major version 50
    Java 7 uses major version 51
    Java 8 uses major version 52
    Java 9 uses major version 53
    Java 10 uses major version 54
    Java 11 uses major version 55

Copy a project from SVN repository to another

Sometimes I program some stuff at home but I need it later on my work office. It is necessary to move the project from my private SVN repository to the work repository. I need all the revisions, not only the latest one.

First at all, I have to dump the project at home:

# svnadmin dump path/to/home/svn > repository.dmp

The path/to/home/svn must be a local path, so you have to work on the repository machine (you cannot use svn+ssh etc.). The dump contains now the whole repository, all revisions. So it can be huge. To filter the relevant project there is a tool called svndumpfilter.

# cat repository.dmp | svndumpfilter --drop-empty-revs --renumber-revs include /path/name_of_the_project/in/svn > project.dmp

You have to use the case-sensitive project name (inclusive the parent folder names within SVN). Now copy the project.dmp to the SVN repository server on your work office. Again you have to work on the repository machine to use a local file path.

To load the project use:

# svnadmin load --ignore-uuid /path/to/work/svn < project.dmp

This will import the project on the root folder / of the repository. It contains all the folders and subfolders of the source repository, where the project was located there. So if your original project path was

/projects/webobjects/example

the destination path will be

/projects/webobjects/example

too. To prevent overwriting existing stuff, you can use the --parent-dir switch during the load operation:

# svnadmin load --ignore-uuid --parent-dir /projects/phosco/examples /path/to/work/svn < project.dmp

So the resulting path will be

/projects/phosco/examples/projects/webobjects/example

You have to move the imported project on the right position later. If you have tested the command above, you have seen an error. This is a problem of the source folder of the project, it doesn’t exist on the destination repository. Before you can load the project dump, you have to create the base folder:

svn mkdir -m "Creating new project layout." file:///path/to/work/svn/projects/phosco/examples/projects

You have to use an URI to access the repository with svn. You cannot use the local path as with svnadmin. It is necessary to create only the first component of the project path (not the deeper subfolders):

Location on the source SVN:
/projects/webobjects/example

Build on the destination SVN:
projects

Together with the parent-dir of the destination repository you have to create a folder
/projects/phosco/examples/projects

Now you can load the project into the destination repository:

# svnadmin load --ignore-uuid --parent-dir /projects/phosco/examples /path/to/work/svn < project.dmp

The last step it the move of the newly imported project to the correct place within the destination repository:

svn move -m "move the imported project to the right location" file:///path/to/work/svn/projects/phosco/examples/projects/webobjects/example file:///path/to/work/svn/projects/phosco/examples/new-example

Oracle JDBC

The URL:

jdbc:oracle:thin:@<server>:1521:<sid>
jdbc:oracle:thin:@<server>:1521/<service_name>

The driver:

oracle.jdbc.OracleDriver

WebObjects and GWT

Today I had the idea, that I could use GWT (Google WebToolkit) together with WebObjects. I’m not a HTML programmer, so my webpages are not really nice. It would be better to develop Javacode and put the web components together with a framework.

On the internet I found a tool to combine WebObjects and GWT: WOGWT.

First I downloaded the GWT plugin for Eclispe 4.6: Install instructions.

First problem could be: the GWT version is now 2.7, but the WOGWT uses 2.5?

Download the WOGWT latest version 0.6 and unzip it into /home/arothe/Libraries/WOnder/Library/Frameworks. Now it is time for a simple Hello World example project. I created a new WebObject Application within Eclipse and added the new WOGWT framework to the build path.

The application doesn’t start, I have to add both ERExtensions and ERJars framework.

Now I have to set the path to the GWT SDK within the Eclipse preferences. But it doesn’t work, because there is not “tools” folder. I think, that is the time to download the whole SDK.

List all directories for group has access to

find ${dir} -type d -group ${group} -perm -g=r -print

Access to Ant properties from IzPack XML

Inside the installation XML the access to Ant properties per

@{ant.property.name}

will only work, if you insert the whole XML content as CDATA into the build.xml

<IzPack output="${dist.dir}/IzPack-install.jar"
        installerType="standard"
        basedir="${dist.dir}"
        IzPackDir="${dist.dir}/">
        <config><![CDATA[
<installation version="1.0">
   <info>
      <appname>@{my.app.name.defined.in.build.xml}</appname>
      ...
   </info>
...
        ]]></config>
</IzPack>

If you use different files, the properties are unknown within the IzPack file. But there is a simple solution: Copy the install.xml into a temporary file and expand the properties during this step.

<target name="installer" depends="jar" description="compiles the IzPack installer">
	<copy overwrite="yes" verbose="yes" file="${dir.install}/izpack/install-definition.xml" tofile="${java.io.tmpdir}/install-definition.xml">
		<filterchain>
			<expandproperties />
		</filterchain>
	</copy>
	<IzPack input="${java.io.tmpdir}/install-definition.xml" output="${dir.dest}/${app.name}-install.jar" installerType="standard" basedir="${basedir}" />
</target>

So you can use ${app.name} inside the install.xml (don’t use @{app.name}). But you shouldn’t use Ant properties, which are redefined by IzPack itself or in a <variable> tag section. These properties are expanded before Ant calls IzPack and could contain the wrong values.

Special characters within IzPack XML

If you need some defined XML entities like é within the IzPack installation XML, you can’t use it there. The reason: they aren’t defined. But you can define a subset within your XML:

  <?xml version="1.0" encoding="iso-8859-1" ?>
  <!DOCTYPE installation [
  <!ENTITY % iso-lat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML"
                    "http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent">
  %iso-lat1;
  ]>
  <installation version="1.0">
    <!-- start here -->
  </installation>

These additional lines include the usual entities. It is now possible to use:

  <authors>
    <author name="Andr&eacute; Rothe" email="andre.rothe@domain.local" />
  </authors>

Safe copy of directories

Use


rsync -avx --progress /source/ /dest

to copy the complete content of /source into /dest, the source folder itself wont be copied (trailing /). Remove the slash and you will copy the /source folder and its content into /dest.

Use


rsync -avx --progress /source/ user@remote-host:port/dest

for syncronization between workstations.