Categories
Tech

Java auf dem Uberspace

Java ist auf dem Uberspace nicht vorinstalliert. Kann man aber total einfach selbst installieren:

toast add http://download.oracle.com/otn-pub/java/jdk/7u17-b02/jdk-7u17-linux-x64.tar.gz
toast get jdk
toast build jdk
toast arm jdk

Das war es schon. Danach ist Java installiert und kann benutzt werden. Aber bitte beachten, dass es sich um einen Shared Host handelt, also nicht zu verschwenderisch mit CPU und RAM umgehen.

Categories
Tech

MouseOver mit Selenium-WebDriver

Manchmal™ möchte man Webseiten testen, die ein Menü einblenden, wenn man mit der Maus über einem Element ist. Folgender Code für Selenium WebDriver macht genau das:

protected void mouseOver(WebElement element) {
    String code = "var fireOnThis = arguments[0];"
                + "var evObj = document.createEvent('MouseEvents');"
                + "evObj.initEvent( 'mouseover', true, true );"
                + "fireOnThis.dispatchEvent(evObj);";
    ((JavascriptExecutor) driver).executeScript(code, element);
}

Categories
Tech

LWUIT on MicroEmulator on iPhone

I tried to run the LWUIT Demo with my MicroEmulator iPhone port. Here are some screenshots:

First Try. Got the clipping slightly wrong…

After a quick fix, clipping correct, but no text…

Changing to another theme…

… the text is there!

Menu is workin.

Setting some dialog properties, and…

… displaying it.

Some more screenshots…

Performance is slow as hell, not all graphics are rendered properly, but its working at least.


Categories
Tech

MicroEmulator on iPhone

I have started porting microemulator to (jailbroken) iPhones. Here are some first screenshots.

Categories
Tech

Using Maven2 to build Cydia Packages for the iPhone

I am using Maven2 for most Java projects. So I wanted to use it for Phone-Java development, too. This is a little tutorial on how it can be done.

iPhone Cydia Packages are Debian .deb files really and luckily there is the mvn-pkg-plugin that supports creating .deb files with Maven2. Unfortunatly the current version has a bug, so that it won’t work out of the box for creating iPhone packages. So you have to grab the latest svn-snapshot and apply the following patch.

 

Index: src/main/java/de/tarent/maven/plugins/pkg/map/Parser.java
===================================================================
--- src/main/java/de/tarent/maven/plugins/pkg/map/Parser.java	(revision 132)
+++ src/main/java/de/tarent/maven/plugins/pkg/map/Parser.java	(working copy)
@@ -62,7 +62,7 @@

       if (auxMapDocument != null)
         {
-          s = new State(packageMapDocument);
+          s = new State(auxMapDocument);

           s.nextMatch("package-maps");
           parsePackageMaps(s);


 

After applying the atch and doing a “mvn install”, we can start with the real work. Download the tutorial files from here. I will explain the contents of the archive later. For now unzip it and do a “mvn package” in its directory. It will compain about some missing dependencies, so grab the missing jars from your iPhone and install them in your Maven reposiory as directed in the error message. After you have done that another “mvn package” shoud produce a .deb file in the target subdirectory. You can upload this to your iphone and install it with dpkg. After a restart of the SpringBoard a new icon HelloMaven should be on your screen, that should start the demo program.

Now some explanation of how it works. The main part is done in the pom.xml. Here is the relavant excerpt form this file:

	de.tarent.maven.plugins
	maven-pkg-plugin
	
		iphoneos
		Arindal Tune Helper
		
			HelloJava
			
example
iphoneos-arm /Applications/HelloMaven.app Info.plist icon.png Starter postInst.sh preRm.sh file:${basedir}/pm-iphoneos.xml package pkg


The first important part is the defaultDistro tag. Here we tell the plugin, that we want to build a package for the iPhone. Unfortunatly there are no default iPhone mappings contained in the plugin. That is why we have the auxPackageMapURL tag, that tells the plugin where to look for the Maven-to-Cydia-Package-Mapping. Most other things should be pretty self explaining.

The files in the dataFiles Section have to reside in src/main/auxfiles icon.png and Info.plist should be pretty clear. The Starter entry needs some explanation though. The plugin automatically generates a start script in /usr/bin. This is good enough for console applications, but if you want to start a GUI-App some more work is needed. The Starter script sets the Java executable path to /Applications/Appname.app/Java and calls the generated script after that. For this to work the starter Script has to get executable permissions and jamvm has to be linked to /Applications/Appname.app/Java. This is done in the postInst.sh script. For more info about those scripts and what you can do there refer to the Debian documentation.

This should be enough to get you started, if cou have questions, please feel free to post them in the comments.

Categories
Tech

iPhone Java First Try

Made my first tries with Java on a jailbreaked iPhone 3G. Here is a screenshot of some drawing routines. Its reacting on touch events, too. Will write more about it later.

So die ersten Versuche mit iPhone Java Entwicklung sind gemacht. Hier mal ein Screenshot von ein paar Grafikausgaben. Reagiert auch schon auf Touch Events. Spaeter mehr davon.

photo

Categories
Tech

Parse Command Line Options with annotations

Panzi has written a very nice Lib to parse command line options in Java. You can just add Annotations to your Java fields and they will be filled automagically with the command line values.

Eine sehr nützliche Lib um Kommandozeilen in Java zu Parsen hat Panzi in seinem Blog beschrieben. Dazu werden die Felder im Java Code einfach mit bestimmten Annotations versehen und die Lib kümmert sich um das Parsing und schreibt die Werte direkt in die Felder.