Install the java plugin in firefox

To install the Next-Generation Java plugin in firefox follow the instructions below which is a summary of this article. If you have been using the classic plugin, see the Notes for further information.

  1. Check if you’re using the 32-bit firefox. Select the menu item Help -> About Mozilla Firefox. At the bottom of the window is a version string line that contains either “Linux i686″ (32-bit) or “Linux x86_64″ (64-bit). If you use the 64-bit version have a look at this blog post else continue.
  2. Exit Firefox.
  3. Change to ~/.mozilla/plugins or to another firefox plugins directory.
  4. Remove all symlinks (or move them to another directory).
  5. Create a symlink for the 32-bit plugin. Execute one of the following lines
    ln -s ${JRE_HOME}/lib/i386/libnpjp2.so
    ln -s ${JAVA_HOME}/jre/lib/i386/libnpjp2.so

    depending on what environment variable you have set. If you don’t know where your java is located find it out with which java or locate java

  6. Start firefox.
  7. Type about:plugins in your location bar to confirm that the java plugin is loaded.
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Run a JavaFX application

Oracle claims that

JavaFX applications will run on any desktop and browser that runs the Java Runtime Environment …

but if I try to run it with my jre I get this error:

java de.slopjong.App
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/javafx/runtime/FXObject
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Caused by: java.lang.ClassNotFoundException: com.sun.javafx.runtime.FXObject
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 12 more
Could not find the main class: de.slopjong.App.  Program will exit.

If I’m not wrong this means that a JavaFX application requires more than just the Java Runtime Environment. Somewhere else in the JavaFX documentation I read that it’s compiled into java byte-code but this seems to be not the whole story. I understood this as you can run a JavaFX application with your standard jre.

Why should I use JavaFX for graphical user interfaces if the users must have the JavaFX libraries on their computer? I don’t want to force them to install one more piece of junk!

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Maven, the better quickstart

I read a lot of Maven documentation and at the end the most interesting question “How do I run an application with its dependencies?” wasn’t answered. Instead I was flooded with many xml configuration sections without showing a simple and complete configuration file. That’s why I wrote this howto but first a little story.

I came across Ivy and Maven a couple of days ago, both of which make it very easy to add a list of libraries to your Java project and add them to the classpath.

Basically both look for a project configuration file including your dependency list and they download the libraries from the internet and install them in the local repository ~/.ivy2 for Ivy and ~/.m2/repository for Maven which are then shared with your Ivy/Maven projects.

While Ivy is only a dependency manager which is integrated with the most popular build management system for Java projects (Ant), Maven is more than just such a manager. With Maven you have a build system and a dependency manager in one tool.

I focused on Maven and it took me a while to find out that a feature I was looking for wasn’t there natively. I assumed it would have a similar behaviour than Ivy but it hasn’t and works completely different.

I was missing a clear Maven howto which shows in 5 minutes how your project is created, compiled, packaged and especially how your standard java application is run afterwards.

I assume that Maven is already installed and that you are familiar with using a shell as I won’t use m2eclipse, the Maven integration for Eclipse. Maybe I’ll update this post later and give you a little introduction but for now let’s concentrate on using it in a shell.

I don’t guarantee that everything is 100% correct because I don’t use Maven that long. Post a comment if something is wrong.

Continue reading »

DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

WebService.class not found

[javac] An exception has occurred in the compiler (1.5.0_18). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
[javac] com.sun.tools.javac.code.Symbol$CompletionFailure: file javax/jws/WebService.class not found

If you get such an error the JSR 181 is missing.

I added the following Ivy dependency to fix the issue while I’m using http://mvnrepository.com/artifact as my repository root.

<dependency org="javax.jws" name="jsr181-api" rev="1.0-MR1"/>
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare

Installing buildr

Installing buildr

sudo gem install buildr -v 1.3.5

recently failed. I got an environment variable JAVA_HOME not set error which was definitely set to /System/Library/Frameworks/JavaVM.framework/Home in ~/.profile.

I noticed later that exporting the java home in that file unfortunately doesn’t have an effect on the environment variables under sudo. The trick is to pass it to sudo.

sudo env JAVA_HOME=$JAVA_HOME gem install buildr -v 1.3.5
DeliciousDiggTechnorati FavoritesRedditLinkedInFacebookSpurlTwitterWebnewsYiGGMySpaceYahoo BookmarksFriendFeedGoogle BookmarksLiveJournalShare