Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

17 July, 2011

Setting up Fedora Core 15 with Gnome 3 for Java Development

After installing fc15:

Update the system

$ yum -y update
$ yum install kernel-devel
$ reboot


I've an nvidia driver, that just works with the default driver (nouveau) but it doesnt use the full potential of the nvidia card, so I needed to install the official Nvidia drivers via rpmfusion:

$ rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
$ rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
$ yum install akmod-nvidia xorg-x11-drv-nvidia-libs
$ vi /boot/grub/grub.conf


and check if it's added

rdblacklist=nouveau nouveau.modeset=0

in the kernel line

Then:
$ reboot


After that, you might need to install Oracle Java in the desktop

Download Oracle JDK latest version
Execute:

$ chmod +x /path/to/file/jdk-6u25-linux-*-rpm.bin
$ /path/to/file/jdk-6u25-linux-*-rpm.bin
$ alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000
$ alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000
$ alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
$ alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000
$ alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 20000


Some commands to test everything is ok:

$ java -version

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)

Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

$ javac -version
javac 1.6.0_22

$javaws
Java(TM) Web Start 1.6.0_22


Until now you have a whole OS with desktop and Java tools, but you cannot program without a little bit of multimedia:

Flash plugin (64bits, if you have 32 bits machine, the commands are slightly different):

$ rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
$ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
$ yum install flash-plugin nspluginwrapper.x86_64 nspluginwrapper.i686 alsa-plugins-pulseaudio.i686 libcurl.i686


Bluetooth service works out-of-the-box in FC15 in my dell computer, but it's necessary to enable the service, otherwise you see the bluetooth icon in an undefined status.

$ systemctl status bluetooth.service

bluetooth.service – Bluetooth Manager
Loaded: loaded (/lib/systemd/system/bluetooth.service)
Active: inactive (dead)
CGroup: name=systemd:/system/bluetooth.service

$ systemctl enable bluetooth.service

ln -s ‘/lib/systemd/system/bluetooth.service’ ‘/etc/systemd/system/dbus-org.bluez.service’
ln -s ‘/lib/systemd/system/bluetooth.service’ ‘/etc/systemd/system/bluetooth.target.wants/bluetooth.service’

systemctl start bluetooth.service


Now to wath videos and MP3 you need xine and codecs:
$ yum install gstreamer-plugins gstreamer-plugins-* xine xine-*


The default theme in FC15 is minimalistic and dark, it only needs a few changes:
$ gsettings set org.gnome.shell.clock show-seconds true
$ gsettings set org.gnome.shell.clock show-date true
$ vi /usr/share/themes/Adwaita/metacity-1/metacity-theme-3.xml
$ vi /usr/share/gnome-shell/theme/gnome-shell.css

... and if the font it's bigger than you can bear, just check out Universal Access Settings and make the font size smaller.


# If you are a chrome fan, flash might not work in the 64 bits environment, it needs an small fix:

sudo mkdir -p /opt/google/chrome/plugins
sudo ln -s /usr/lib64/mozilla/plugins-wrapped/nswrapper_32_64.libflashplayer.so /opt/google/chrome/plugins/nswrapper_32_64.libflashplayer.so


And voilá, you have a fully functional linux environment so that you can create the most amazing Java programs in the world :P.

Mr H.

05 May, 2010

Linux Java Hotspot/Gcj error

I got a really nasty Java error while trying to start a formerly working instance of glassfish v2.1.

I tried:
$ bin/asadmin create-domain
bin/asadmin: line 7: /home/h/run/gf21/lib/admin-cli.jar: Permission denied
Failed to load Main-Class manifest attribute from
bin/..//lib/admin-cli.jar

for some reason it didn't allow me to run such jar when previously was working like a charm! I just added execution permission to the jar file:

chmod +x lib/admin-cli.jar

this was all the problem with glassfish, but when solved the issue, this lend me to the next step...

$ bin/asadmin
invalid file (bad magic number): Exec format error
Failed to load Main-Class manifest attribute from
bin/..//lib/admin-cli.jar

OMG!! WTF??? this was just crazy. I googled it a bit and found out that the problem was my java version. I have uninstalled lots of times java-gcj and java-gcj-compat packages from my linux box (FC12), but everytime I update software it installs them again, therefore sometimes I just ignore I have it again in my system. This level passed! time to go to the next level!

Now that I uninstalled java-gcj again (with nodeps option otherwise I would uninstall openoffice), I tried again, now with glassfish installer. At the moment I was a bit demoralized by asadmin problem and wanted to isolate the real issue.

Then I ran:
$ /usr/java/latest/bin/java -Xmx256m -jar glassfish-installer-v2.1.1-b31g-linux.jar
Exception in thread "main" java.io.IOException: Cannot run program "java": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:466)
at glassfish.main(glassfish.java:97)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 3 more

...that got me mad immediatly. What's this error?? I checked some forums and many of them said something about the path where you're executing the main class and so... This was not exactly my case because I got correctly the main class. In this forum they had a similar problem http://forums.java.net/jive/message.jspa?messageID=244886 so I just checked everything again.

The problem was solved with the simple command:
$ export PATH=$JAVA_HOME/bin:$PATH

previously I had correctly defined JAVA_HOME.

Conclusion

When java-gcj is installed, it adds a soft link in /usr/bin/java pointing to gcj java binaries. Therefore any program tries to execute java from there, but it doesn't corresponds to JAVA_HOME. When I removed gcj all my environment was still configured (not by me) to execute java from /usr/bin so it just didn't find JDK binaries. That's why just adding the proper java binary to the path, it worked again.

I have to complain to FC12 packagers because we all know that gcj it's not in a stable and fully compatible state, therefore it's very frustrating that you need to remove gcj and download/install Sun JDK. What's most frustrating it's that openoffice depends strongly on gcj and don't let you choose what JVM you wanna work with.

Supposedly Linux it's all about choice, and when sun jdk it's still not opensource, it's completely free tough, so it should be a way to FC12 packagers to let the users choose between JDK's.

Hope this helps anyone.

13 March, 2010

Trust SSL Certificate in Java

This is an small article about how to trust a SSL certificate using Java. Very interesting and useful.

http://en.wikibooks.org/wiki/WebObjects/Web_Services/How_to_Trust_Any_SSL_Certificate