Posts belonging to Category Java



3D HTML5 games for iPhone

I been looking for a good 3D JavaScript engine that will allow us to make some kind of html5 game on a mobile but none of them really work on iphones.
Today I found this: https://github.com/mrdoob/three.js#readme

Most of the examples do not work with an iphone as they have to many polygons but some do work at 30 frames per second !

These work well in iPhone (3Gs):
http://mrdoob.github.com/three.js/examples/canvas_geometry_cube.html
http://mrdoob.github.com/three.js/examples/canvas_interactive_cubes.html

This one does not work on iphone (you need to be able to click) but looks like fun. Create a 3d model here: http://mrdoob.com/projects/voxels/ When you finish creating your 3D model the url will be longer copy it to your iphone and you will see your 3d model.

ZK – Communicating with the server

Using Javascript instead of zscript  to calculate a value means you don’t have to communicate with the server until necessary but how do you send data back to the server? I could not find a complete answer so here is my answer below:

In your zul page you will need a textbox (hidden if you want)

<textbox id="serverComm" class="serverComm"></textbox>

Your Javascript put something like this to trigger event

    zk.Widget.$($(".serverComm")).setValue("value to send");
    wid = zk.Widget.$($(".serverComm"));
    zAu.send(new zk.Event(wid, 'onUser', location));

In your “GenericForwardComposer” you need to listen for the event:

	Textbox serverComm;
	public void onUser$serverComm(Event event) throws Exception {
		Event eventx = Events.getRealOrigin((ForwardEvent)event);
		String test = eventx.getData().toString();
		System.out.println(test);
	}

So you don’t make the same mistakes I made:

  • don’t make your on event like “onMyEvent” I think  “onUser” is an event made just for this.
  • I tried sending value without the textbox but it just did not work.

 

java.lang.OutOfMemoryError: PermGen

For the past few days a been getting an error when Jenkins deploys to Tomcat

unable to load xyz due to java.lang.OutOfMemoryError: PermGen space

Apparently this can occur after redeploying an application a few times and the solution is to add the options below to the JVM command line

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

I will post later if it worked. will try it

Update: it didn’t work so will update later with what did work if i find out

MySQL @Transactional @Rollback not working!

I been doing some junit tests and suddenly the @Transactional annotation was not working. I checked all my code and I could not find why.

	@Test
	@Transactional
	@Rollback(true)
	public void testCreate(){}

After comparing other test that were working I found that the problem was the MYSQL engine that I was using did not support it so changing it to InnoDB fix it!

Eclipse install

Here is my check list of things I install before I can start coding on anew machine

  • Maven
  • Eclipse
  • maven plug-in useless
  • SVN plug-in
  • Download tomcat and add server

Maven plugin

I tried a fresh new install with the plugin below but it just dosen’t work

http://m2eclipse.sonatype.org/installing-m2eclipse.html

bug is similar to these one:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=330896

The only way to install plug-in is to install spring plug-in first

Java print date (calendar) dd/MM/yyyy

This code is very simple but when I need it I always forget how to do it and i spend to long searching for it.

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import org.junit.Test;

public class ManualOverrideProcessImplTest  {

	@Test
    public void test1() {
		Calendar today = new GregorianCalendar();

		SimpleDateFormat df = new SimpleDateFormat();
		df.applyPattern("dd/MM/yyyy");
        System.out.println(df.format(today.getTime()));
	}

}

Also it is very easy to create a static String but a Date takes a little more work

    public static final Date END_DATE;
    static{
    	DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    	try {
			END_DATE = (Date)format.parse("9999-12-31");
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
    }

END

ZK, Spring, AOP, Security, Hibernate, Hibernate-Generic-DAO, Jasper

I been looking for a good example that has ZK, Spring, Spring Security and Hibernate and this example looks perfect and it is well documented

http://vs171030.vserver.de/test/pages/index.zul

the sample app is hosted here

http://vs171030.vserver.de/test/

Some more info on ZK with Spring-security

http://www.zkoss.org/smalltalks/zkspringsec1/

ZK studio only works with Eclipse Galileo and I at this time I think i need an older version of Java SDK

http://www.oracle.com/technetwork/java/archive-139210.html

 

Spring, -AOP, -Security, Hibernate, Hibernate-Generic-DAO, Jasper

Blender book

So busy at work I don’t have time for this extra project. As soon as I get some time I want to read this book: http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro

Subversion install

I had to setup subversion today and is always annoying trying a  few servers and plug-ins until you find something that works well or at least does the job and it is free.

Server: VisualSVN http://www.visualsvn.com/server/

Client: TortoiseSVN http://tortoisesvn.net/

Eclipce plug-in: subclipse http://subclipse.tigris.org/update_1.0.x

if you have a win7-64 then you will need to install this too

http://www.sliksvn.com/en/download

http://subclipse.tigris.org/update_1.0.x