wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Getting Java running on RHEL 5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting Java running on RHEL 5" Watch "Getting Java running on RHEL 5" New topic
Author

Getting Java running on RHEL 5

Jon Swanson
Ranch Hand

Joined: Oct 10, 2011
Posts: 200
I installed java 1.6.027 on a windows 7 PC and RHEL 5 linux desktop as I need an application that will work in either environment. The OC install seems to be fine. I am working through "Heads Up Java" and so far, so good. The Linux install was confusing. I used the jdk-6u27-linux-x64-rpm.bin and that seemed to run OK.

./jdk-6u27-linux-x64-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u27-linux-amd64.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Installing JavaDB
Preparing... ########################################### [100%]
1:sun-javadb-common ########################################### [ 17%]
2:sun-javadb-core ########################################### [ 33%]
3:sun-javadb-client ########################################### [ 50%]
4:sun-javadb-demo ########################################### [ 67%]
5:sun-javadb-docs ########################################### [ 83%]
6:sun-javadb-javadoc ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....


Done.

However, my system has links to java-

which java
/usr/bin/java
jon 32>ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 Apr 27 2010 /usr/bin/java -> /etc/alternatives/java
jon 33>ls -l /etc/alternatives/java
lrwxrwxrwx 1 root root 46 May 4 13:14 /etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
jon 34>ls -l /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
-rwxr-xr-x 1 root root 42248 Apr 7 2011 /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
jon 35>ls -l /usr/lib/jvm
total 28
lrwxrwxrwx 1 root root 26 Sep 22 2010 java -> /etc/alternatives/java_sdk
lrwxrwxrwx 1 root root 32 Sep 22 2010 java-1.4.2 -> /etc/alternatives/java_sdk_1.4.2
lrwxrwxrwx 1 root root 22 Sep 22 2010 java-1.4.2-gcj -> java-1.4.2-gcj-1.4.2.0
drwxr-xr-x 6 root root 4096 Jan 13 2011 java-1.4.2-gcj-1.4.2.0
drwxr-xr-x 3 root root 4096 Apr 7 2011 java-1.6.0-openjdk-1.6.0.0.x86_64
lrwxrwxrwx 1 root root 30 Sep 22 2010 java-gcj -> /etc/alternatives/java_sdk_gcj
lrwxrwxrwx 1 root root 21 Apr 27 2010 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 27 Apr 27 2010 jre-1.4.2 -> /etc/alternatives/jre_1.4.2
lrwxrwxrwx 1 root root 26 Apr 27 2010 jre-1.4.2-gcj -> java-1.4.2-gcj-1.4.2.0/jre
lrwxrwxrwx 1 root root 27 Jun 21 2010 jre-1.6.0 -> /etc/alternatives/jre_1.6.0
lrwxrwxrwx 1 root root 37 May 4 13:14 jre-1.6.0-openjdk.x86_64 -> java-1.6.0-openjdk-1.6.0.0.x86_64/jre
lrwxrwxrwx 1 root root 25 Apr 27 2010 jre-gcj -> /etc/alternatives/jre_gcj
lrwxrwxrwx 1 root root 29 Jun 21 2010 jre-openjdk -> /etc/alternatives/jre_openjdk

So step 1. I set the PATH to where I discovered the instraller had put java-

setenv PATH /usr/java/jdk1.6.0_27/bin:${PATH}

After this my really simple test went from giving errors to working-


so far so good. I checked for CLASSPATH in the environment- it's not set.

So now I tried what I really want to do- a GUI example from Head First Java-


works on PC, gives this on RHEL 5-

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at TestGui.actionPerformed(TestGui.java:38)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6288)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6053)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4651)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4481)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:643)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:602)
at java.awt.EventQueue$1.run(EventQueue.java:600)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:616)
at java.awt.EventQueue$2.run(EventQueue.java:614)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:613)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

I am not sure if this is a case where the same code won't run on both platforms or there is something about the funcky RHEL installaation that is not quite right. BTW I get the same error when not using the new PATH. So I can believe I am importing the wrong versions of the libraries, but I don't know how to check this or tell Java where to look (I don't actually know even where I would point to if I wanted to set CLASSPATH.

Could someone suggest a course of action. It's all a but frustrating at the moment.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  18

Welcome to the Ranch!

The installation "problems" are irrelevant. Your Java installation is running just fine, it's just your program that has a bug.


On line 6 you declare a JButton. You try use that JButton on line 31. However, you have never initialized it, so it's still null. You have initialized a JButton called button on line 19, true, but that's a different variable that shadows the field you want to initialize. Just remove the JButton word on line 19 and it should work fine.

And could you please UseCodeTags next time? See how much better your code looks like with them.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jon Swanson
Ranch Hand

Joined: Oct 10, 2011
Posts: 200
Thanks. I will try to use code tags next time. I actually tried the first time, now I see why that didn't work for me also.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Java running on RHEL 5