Thursday, August 4, 2011

XML, XSD with Java and JAXB

Reference: http://www.oracle.com/technetwork/articles/javase/index-140168.html

JAXB is part of the JDK, so you shouldn't have to install anything if you already have the JDK installed.

Process Summary:
1. Make xsd file.
2. Compile it using JAXB compiler to create a java files.
3. Compile java files using a java compiler like javac.
4. Create a jar file from the .class files created.
3. Import jar file.
4. Create XML that complies with xsd.
5. Load xml into parent object from jar file.
6. Start using the object

NOTE: Compiler doesn't recognize whitespace notations in xsd file, so xml file must be careful about whitespace regardless of what the xsd indicates


STEP 0:
Make an xsd file.

Given an XML file, we use a Microsoft tool, XSD.exe to generate an XSD (XML Schema) from it.

From the command line, run:

xsd.exe myFile.xml

This will generate myFile.xsd.

STEP 1:
Using JAXB compiler example:
xjc -p myClass.jaxb myClass.xsd
This creates a directory structure of myClass/jaxb/*.java where all the java files are

STEP 2:
Compile example:
javac myClass/jaxb/*.java -d .
(NOTE: the . at the end is the output directory)

STEP 3:
Jar it example:
jar -cf myClass.jar ./myClass/jaxb/*.class
STEP 4:
First make sure to add your jar that you just compiled and import it, as well as importing javax.xml.bind.*; (or specifically what you need)
Now you ready to code. Example below:

//add package name
JAXBContext jc = JAXBContext.newInstance("myClass.jaxb");

//creating this allows a xml file to be mapped to an object
Unmarshaller unmarshaller = jc.createUnmarshaller();

//map to one of the objects that you compiled above
MyClass obj = (MyClass)
unmarshaller.unmarshal(new File( "myClass.xml"));

Tuesday, July 12, 2011

Deploying MT4j Application Java Executable

First we tried just exporting using eclipse, but we ran into errors with "UnsatisfiedLinkError" referencing "no jogl found" under java.library.path.

Next we tried building a FatJar using the Fat Jar Eclipse Plugin located at fjep.sourceforge.net, and able to be downloaded via eclipse from http://kurucz-grafika.de/fatjar . This yielded similar results, however.

To attempt to remedy this, we copied all of the files referencing gluegen and jogl into the java\jdk\jre\lib\ext directory, which removed the UnsatisfiedLinkError for jogl but popped up with another for Win7Touch . After migrating all files we could find referencing that to the ext folder as well, including some that probably had nothing to do with it, we were still at the same error. Not only was this getting messy, but it was getting us nowhere and would be annoying to set up via batch when deploying on a new pc.

Next, we elected to try moving all relevant files into the JAR (.dlls, .jnilibs, basically everything referencing jogl and win7) into the JAR itself, but this didn't fix any errors.

After hunting around on the forums some more in the morning, we found that one solution was to place all of these files in the same directory, on the same level as the jar file, but not *IN* it. This yielded success.

End result: To make the executable jar file run when using mt4j, move all .dlls, .so's, and *.jnilib's into the same directory as the jar, as well as any pictures or sounds your JAR needs to run properly. For us, the relevant .so's and libraries and such were as follows:

gluegen-rt.dll
jogl.dll
jogl_awt.dll
jogl_cg.dll
libgluegen-rt.jnilib
libgluegen-rt.so
libGlulogicMT.jnilib
libjogl.jnilib
libjogl.so
libjogl_awt.jnilib
libjogl_awt.so
libjogl_cg.so
ManyMouse.dll
ManyMouse.so
Win7Touch.dll
Win7Touch64.dll

Thursday, July 7, 2011

MT4j on Android Tablets

You'll need mt4j-core and mt4j-android from:

http://mt4j.googlecode.com/svn/branches/new/

There is also a test app.

To get it to run you will need to link to the Processing core library
for Android, which is here:

http://processing.googlecode.com/svn/trunk/processing/android/core/

You will need to modify the Processing core:

----- MODIFY ----

therion_> if you can try to set clearcolor to true in the
defaultsetttings() method in pgraphicsandroid3d
[5:54 PM] it didn't crash with an exception, though - the
bg flashed on and off really fast, on touch it would stay the bg
color, then on release it would flash
[5:54 PM] i mean clearColorBuffer
[5:55 PM] oh ok
[5:55 PM] but it didnt crash :p
[5:55 PM] trying clearColorBuffer = true; ...
[5:56 PM] it runs! :)

--- END MODIFY ---

http://wiki.processing.org/w/Android

Newsflash... Reddit is like 9 people

For some reason, it always seemed like Reddit had to be this huge company of programmers and systems administrators or something... it seemed that way in my mind. When I saw their new office space -- I realized I have more programmers sitting in MY office space.

http://blog.reddit.com/2011/07/its-time-for-us-to-pack-up-and-move-on.html

This is somehow empowering for me.

Wednesday, June 29, 2011

Luke W's Touch Gesture Reference Guide

Found this interesting resource for Touch Gestures:

Profiling Java Applications with Eclipse and TPTP

I need to profile some Java applications. I'm using Eclipse as my development environment, so I started looking for tools. The first thing I found was this tutorial using TPTP (http://www.eclipse.org/tptp/index.php):



First, I'm installing the pre-requisites:
  • I already have the JDK

  • Eclipse SDK - http://download.eclipse.org/eclipse/downloads/drops/R-3.6.2-201102101200
  • It looks like this is a replacement of Eclipse with the SDK installed as plugins. I could point it at my current workspace, but I would need to re-install my other plugins (Subversion, JIRA, etc.,.), so I'm going to try to install the SDK plugins in my current Eclipse install.
  • In Eclipse, go to Help, Install New Software and search all available sites for Eclipse SDK. It found 3.6.2.M20110210-1200.
  • EMF - Eclipse Modeling Framework (EMF and XSD)
  • EMF: Install Eclipse Plugin
  • XSD: Shows up in Eclipse plugin directory as XML Schema Definition SDK

Now install the Test and Performance Tools Platform (TPTP)
  • NOTE: I'm NOT installing the WTP and BIRT support for TPTP right now

Wednesday, June 22, 2011

Netflix and AWS

Read through this excellent set of slides about Netflix and how they are using AWS. This documents a lot of their development process, including how they are migrating from the traditional datacenter with systems administrators (SA), DBA, and network admins to a cloud based architecture with a "Cloud Operations Reliability Engineering" team.