Monday, April 22, 2013

Set Sun's JDK as Default on Fedora 18

If you installed Sun's JDK (yes, I still call it Sun's!) from the binary package (versus the RPM) and need to use it as the default implementation, you can manually alter the PATH and JAVA_HOME but the easy way is to, at first let Fedora know about it:

# java
> alternatives --install /usr/bin/java java /opt/java/jdk1.7.0_21/jre/bin/java 20000

# javaws
> alternatives --install /usr/bin/javaws javaws /opt/java/jdk1.7.0_21/jre/bin/javaws 20000

# Java Browser (Mozilla) Plugin 64-bit
> alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /opt/java/jdk1.7.0_21/jre/lib/amd64/libnpjp2.so 20000

# Install javac only if you installed JDK (Java Development Kit) package
> alternatives --install /usr/bin/javac javac /opt/java/jdk1.7.0_21/bin/javac 20000
> alternatives --install /usr/bin/jar jar /opt/java/jdk1.7.0_21/bin/jar 20000


and then set it as the default:

> alternatives --config java
> alternatives --config javac

Source.

Monday, April 15, 2013

Add Installed JDK to Eclipse

If you install a JDK yourself (from a BIN, ZIP or other archive) you can easily add it from Window --> Preferences --> Java --> Installed JREs, choosing Add --> Standard VM and specifying the root directory of the newly unpacked installation.
If the JDK is already installed with the Linux standard directory structure, you should instead specify one of the directories you can find in /lib/jvm.

Create an Eclipse Git Maven Java Project

You need to create a new Eclipse (Juno) Java project from a remote Git repository (like GitHub) managed by Maven (i.e. you already have a pom.xml for your project.)
  1. Make sure you installed a Git plugin like EGit.
  2. Click on File --> Import --> Git --> Projects from Git
  3. Then follow the instructions...
  4. Specify a URI for the repository source. This will end with a file.git.
  5. Select a branch.
  6. Local destination (<Git's_local_repository>/<project_name>)
  7. Select Import existing project.
  8. Select create Java project.
  9. Select Use custom location. This should be the local Git repository location.
  10. Mavenize it: right-click on the project's name --> Configure --> Convert to Maven project.

Friday, April 12, 2013

Export Java Syntax Coloring Preferences from Eclipse Juno

I just found out that trying to export just the Java syntax coloring preferences from Eclipse Juno doesn't work.
These are the color preferences you set from Window --> Preferences --> Java --> Editor --> Syntax Coloring.

Theoretically you should do a File --> Export --> General --> Preferences, select Java Code Style Preferences (I don't have a Syntax coloring item) and get them in your favorite file.epf
They should be included in those.

It doesn't work. But you can get them if you select export all.
I don't know if this is a bug or not...