Installing Java plugin in Google Chrome Beta on Fedora 12

January 28, 2010 by Bozhidar

The Java plugin is one of the few things that don’t work out of the box in the recently released Google Chrome Beta for Linux. Thankfully it’s not that hard to set it up. Here I’ll show you how to get the Java plugin up and running on Fedora 12, but the procedure is mostly the same on all Linux distributions.

First you need to install Java(preferably Sun’s edition since the OpenJDK’s plugin seems to be very buggy at the moment). I’d recommend you to follow the instructions outlined here.

Then type the following commands as root(or with su):

mkdir /opt/google/chrome/plugins
cd /opt/google/chrome/plugins
ln -s /usr/java/default/jre/lib/i386/libnpjp2.so .

Restart Google Chrome if it was running and you should be ready to go. You can check if everything went well by typing “about:plugins” in the URL bar – this will show you a list of all

presently installed plugins.

Auto-increment entity id in Hibernate/JPA backed by Hibernate

January 17, 2010 by Bozhidar

This is really simple:

@Entity(name = "SomeEntity")
public class SomeEntity implements Serializable {
@Id
@GenericGenerator(name = "generator", strategy = "increment")
@GeneratedValue(generator = "generator")
private long id;
...
}

The important part that most people are having hard time to discover is org.hibernate.annotations.GenericGenerator(maven users will find it in the hibernate-annotations artifact). Obviously this solution is Hibernate specific, but if you’re using Hibernate it will suit you just fine.

How to post source code snippets in blog posts

December 18, 2009 by Bozhidar

Wondering how to post a code snippet in your WordPress blog, so that the snippet would get a proper syntax highlighting? Look no further than the “sourcecode” tag.

More details can be found in this support article.

How to center a JDialog over a JFrame in Swing

December 18, 2009 by Bozhidar

I always thought that the fact that JDialogs accepted a parent frame as a constructor argument was the thing, that would make the dialog’s position relative to that of the frame:


public JDialog(final java.awt.Frame parent, boolean modal)

Unfortunately all of my freshly opened dialogs would appear in the upper left angle of my screen, not centered over the parent JFrame. I looked around and found out that I simply needed one more method call per dialog:


theDialog.setLocationRelativeTo(theFrame);

You need to call this method before the JDialog’s show() method. Now everything is perfect and the dialog appears always right above the center of the frame.

Automatically execute programs after zsh login

December 5, 2009 by Bozhidar

Sometimes you may want to start a couple of programs just after an interactive login to your favourite shell, which in my case would be zsh. For example – I use Emacs as daemon process. I cannot use an init script to start it since the daemon is usable on a per user basis. The solution in this case is really simple – just create a .zlogin file in your home folder and put in it all the commands you want executed after you’ve logged into the shell.
In my case I put “emacs –daemon” there and I soon as I’m logged in, the Emacs daemon is up waiting for incoming connections.

Accessing the menu bar in Emacs

December 5, 2009 by Bozhidar

Have you ever been wondering how to access the Emacs menu bar, when using Emacs in console mode? The answer is easy – press F10 or type “M-x menu-bar-open”(both methods work in X as well, of course).
Although the menu bar is rarely used by seasoned Emacs veterans, exploring it is a great way to get started with the capabilities of the new modes, so being able to use it is generally a good thing.

Oracle finally states its intentions regarding the future of NetBeans, GlassFish and VirtualBox

October 30, 2009 by Bozhidar

The Oracle acquisition of Sun Microsystems has generated a lot of excitement over the last months. It also generated a lot of uncertainty and fear about the future of some the popular open source projects sponsored heavily by SunĀ  – such as the great NetBeans IDE, the GlassFish Application Server and the VirtualBox virtualization software. I use all them to some extent in my day-to-day work, so I was very happy when I found this document, stating Oracle’s intention to keep supporting all those projects in the future.

So if you were curious to try any of them, but were holding back, because you were not certain if the projects will exist tomorrow – now is the time to give them a shot. I promise you, that you won’t be disappointed.

Using Xerox Phaser 3117 on Fedora 11

September 25, 2009 by Bozhidar

The driver selected by default by Fedora 11 is not appropriate for Xerox Phaser 3117 – it will not print with it. However there is a very easy solution to the problem.

Go to System -> Administration -> Printing (In GNOME at least, in KDE it’s probably something similar). Right click the Xerox Phaser 3117 printer icon there and select “Properties” from the menu. Then in the “Make and model” section choose change and then select Samsung ML-1710.

After you apply the change you’ve just made, you can start printing with your Phaser.

Useful options for running Chromium/Google Chrome

September 4, 2009 by Bozhidar

By default a lot of stuff is disabled in Chromium/Google Chrome – support for plugins(Flash, Java, Real Player, etc.), support for extensions, support for user Greasemonkey scripts. Though there are not a lot of Chromium extensions around and few people use user Greasemonkey scripts, most people would not mind some plugin support. So, here we begin.

To enable plugin support start Chromium in this manner(executable file name is google-chrome for Google Chrome):

chromium-browser --enable-plugins

To enable support for extensions use:

chromium-browser --enable-extensions

And finally for user scripts you can start Chromium like this:

chromium-browser --enable-user-scripts

Of course you can combine them all in one mighty:

chromium-browser --enable-plugins --enable-extensions --enable-user-scripts

(this is the way I run Chromium).

If you use the official Fedora build – the Chromium launcher added to your menu uses all of the above options. In Ubuntu, however, you’ll have to add them by hand to your startup string.

Mofidy JVM parameters for JBoss AS

September 3, 2009 by Bozhidar

Most people have been in a situation requiring them to change one or more of the parameters passed to the JVM on top of which JBoss AS is running. For instance – you may need a bigger heap, bigger perm gen size or something else. The best place to put these parameters is probably the following file:

$JBOSS_HOME/bin/run.conf

where $JBOSS_HOME refers to the directory in which you’ve unpacked the JBoss AS distribution.

Look for this section:

if [ "x$JAVA_OPTS" = "x" ]; then
JAVA_OPTS=”…”
fi

All you have to do now is adapt it to your needs.