Posts for Tag: java

'OSX Mavericks "You need a Java 6 runtime to run X" error dialog fix'

Ok, so here's the deal: If you upgrade to [OSX Mavericks](, only had JAVA 7 installed, and try to run anything that requires JAVA you will probably get a nice dialog like this one:

All my attempts to make Mavericks use JAVA 7 instead have failed so i tried the next best thing: Install JAVA 6. Since you can't find JAVA 6 for Mac at the [Oracle]( site, you'll have to install it from here: [Java for OS X 2013-004](

After installing you'll end up with this following structure at the "/System/Library/Frameworks/JavaVM.framework/Versions" folder:

drwxr-xr-x 11 root wheel 374 29 Ago 14: lrwxr-xr-x 1 root wheel 10 29 Ago 14:58 1.4@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 29 Ago 14:58 1.4.2@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 29 Ago 14:58 1.5@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 29 Ago 14:58 1.5.0@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 29 Ago 14:58 1.6@ -> CurrentJDK lrwxr-xr-x 1 root wheel 10 29 Ago 14:58 1.6.0@ -> CurrentJDK drwxr-xr-x 7 root wheel 238 29 Ago 14:58 A/ lrwxr-xr-x 1 root wheel 1 29 Ago 14:58 Current@ -> A lrwxr-xr-x 1 root wheel 59 29 Ago 14:58 CurrentJDK@ -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents

So you might want to fix the path to the current JDK, so that you keep using the JDK 7 by default (Eclipse users, you know what i mean ;)):

$ sudo rm CurrentJDK $ sudo ln -s /Library/Java/ $ sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents CurrentJDK

Another thing you might need to change is the JAVA_HOME environment variable but, since that depends on whatever shell you use, [Google it]( ;)

Finally, verify that you are still using JAVA 7 by default:

$ javac -version javac 1.7.0_25 $ java -version java version "1.7.0_25"

Have fun.

JAVA vertical gradient background panel

Recently i had to create a gradient background for one of the panels in our [POS application](, so i though i'd share the code.

You need to pass the top and bottom colors of the gradient and also make sure that any panels inside this one are transparent (i.e. setOpaque(false)), otherwise they will paint above it.

import java.awt.Color; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints;

import javax.swing.JPanel;

public class VerticalGradientBackgroundPanel extends JPanel {

private Color topColor; private Color bottomColor;

public VerticalGradientBackgroundPanel(Color topColor, Color bottomColor) {

this.topColor = topColor; this.bottomColor = bottomColor; }

@Override protected void paintComponent(Graphics grphcs) {


Graphics2D g2d = (Graphics2D) grphcs;

g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); GradientPaint gp = new GradientPaint(0, 0, topColor, 0, getHeight(), bottomColor); g2d.setPaint(gp); g2d.fillRect(0, 0, getWidth(), getHeight()); } }