Java

Installing sun-java6 in Ubuntu Maverick Meerkat

Ubuntu 10.10 Maverick Meerkat comes with open-java6. Sometimes you will also need Oracle Java which is now available in Ubuntu partner repositories. This can be done in few simple steps:

  • open Ubuntu Software Center
  • select Edit | Software Sources
  • select Other Software tab
  • select Canonical Partners and click on Close

If there is no Canonical Partners to select, then you might upgraded from Lucid to Maverick and this line got lost from the source.list. Make sure that you have these two lines in the /etc/apt/sources.list:

deb http://archive.canonical.com/ubuntu maverick partner
deb-src http://archive.canonical.com/ubuntu maverick partner

Now, you need to install java.

$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

If you only need the run-time environment, then you can use sun-java6-jre instead. There, you are all set now. You will probably want to export your JDK_HOME first.
Like this:

$ export JDK_HOME=/usr/lib/jvm/java-6-sun

XMLbeans scomp fails with “java.io.IOException: CreateProcess error=2, The system cannot find the file specified”

Beans Alubia pinta alavesa. Álava, Spain.
Image via Wikipedia

If you are using xmlbeans on Windows to bind your schema to Java types then you are probably using a tool bundled with the distribution called scomp or Schema Compiler. For schema compiler to work you will need to correctly setup computer environment by installing JDK. You can follow through the following check-list to detect if any additional installation steps are required on your machine setup:

  • Start->Run->type cmd and type java in the command line. If no error then your setup is correct; otherwise setup JAVA_HOME and add %JAVA_HOME%/bin to your Path environment variable and try again.
  • Start->Run->type cmd and type scomp in the command line. If no error then your setup is correct; otherwise setup XMLBEANS_HOME and add %XMLBEANS_HOME%/bin to your Path environment variable and try again.

Then run scomp. Depending on your wishes you will probably wan’t to create a .jar file of the Java types scomp compiles from schema files. I used the following command line:

scomp -d schema -src src -out my_schema_1_0_0.jar ./schema/mySchema.xsd

where mySchema.xsd file was stored in ./schema folder.

If you get my_schema_1_0_0.jar, by some coincidence then kudos to you, but most likely you will end up with something similar to this error:

Time to build schema type system: 1.282 seconds
Time to generate code: 18.687 seconds
java.io.IOException: Cannot run program "C:\your current path\javac": CreateProcess error=2, The system cannot find the file specified
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
java.io.IOException: Cannot run program "C:\your current path\javac": CreateProcess error=2, The system cannot find the file specified
 at java.lang.ProcessBuilder.start(Unknown Source)
 at java.lang.Runtime.exec(Unknown Source)
 at java.lang.Runtime.exec(Unknown Source)
 ... 6 more
BUILD FAILED

Read on to solve this problem.

Sketchy musical factory

The Abstract Factory pattern illustration, UML...
Image via Wikipedia

Today we will take a look at the abstract factory design pattern. This design pattern continues the series of creational patterns.

In previous article we have talked about factory pattern. We have learned that factory pattern deals with creation of other objects. Now we will extend that knowledge with the abstract factory pattern which provides a way to group together or rather encapsulate a group of individual factories that create objects with common theme.

Normally we would code a client software to create a concrete implementation of the abstract factory and then use generic interfaces to create concrete objects that are tuned to specific theme but, the client does not know about which concrete object will it get from each of the internal factories since it uses generic interfaces of the factory product in question. Details of the implementation of concrete objects are hidden by the internal factories.

Eclipse Galileo and SVN support

Like many Java developers I had to take a look at Eclipse Galileo. My interest lie in how fast I can migrate from Eclipse Europa to new Galileo version.

Installation was as simple as in previous version. Extract an archive file to a directory. Simple eh ? Let’s see what will be broken. Upon first start Galileo tries to move my default workspace. Well I choose my old workspace and by some magic it was opened without problems. Or did it? Recompilation and reformatting took about a minute or two. After that everything worked smoothly. Almost everything.  Project team collaboration vanished.

“GULP”, was my first reaction. CVS support is included, but who really uses CVS nowadays? So I found out that setting up SVN in Eclipse Galileo was not as simple as I thought it to be.

  1. Help->Install New Software
  2. Choose to work with Galileo – http://download.eclipse.org/releases/galileo
  3. Unfold Collaboration
  4. Choose Subversive SVN Team Provider (Incubation)
  5. I employ you to restart Eclipse and don’t use any plugin at this point since they will not work and you will get a message which is similar to this: 0x0040010b: Obtain Project Name’ operation finished with error: Selected SVN connector library is not available or cannot be loaded …’. Instead you rather install a connector library.
  6. Help->Install New Software
  7. Add a site
  8. I used: http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/ , but you can probably use any other that has SVNKit or JavaHL connector
  9. Unfold Subversive SVN Connectors
  10. Select Subversive SVN Connectors, SVNKit (1.3.0), JavaHL (1.6.0) and it’s native libraries.
  11. Restart Eclipse
  12. Configure SVN Connector by specifying the connector in Window->Preferences->Team->SVN->SVN Connector.

And there you have it. Eclipse Galileo with SVN support in all its splendor.

Reblog this post [with Zemanta]

Fungi Factory without abstraction

Next creational pattern that we will have a closer look at – is Factory pattern. There are at least two different Factory patterns, Factory method and Abstract Factory. In this installment we will be looking at the Factory method pattern.