Find the answer to your Linux question:
Results 1 to 8 of 8
Hello there, First of all I'd like to say that I'am a total newbie to Linux. I just got out of the Windows sandbox and have been playing with Linux ...
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    3

    Unhappy Jdk 6 difficulty on Suse 10.1

    Hello there,

    First of all I'd like to say that I'am a total newbie to Linux. I just got out of the Windows sandbox and have been playing with Linux on my comp for the past three days. So if I do sound ignorant, please forgive me, you see I really am!

    So now that I had struggled through getting mp3 and video playback(amarok and kaffeine respectively) I needed java on the system, since I would be working with a lot of java files. Mainly to simulate some network security protocols and this new IDS that I've been working on.

    So I had downloaded the self-extracting file with rpm from the official webpage.

    It is jdk-6-i586. Also dloaded jre-6-i586.

    *Installation procedure I followed was to execute them in console was by drag dropping the file icon onto the command line, getting the path and then running the file. The installation claimed it was succesful.

    Now here's the pain, I wrote a basic "Hello world" java program and compiled it.

    -->javac Hello.java

    It compiled without any errors. Now when I type java Hello to run it I get a NoClassDefFoundError. I double checked to make sure the Hello.class file was created and it was and that too in the same directory.

    Below I've tried to give you whatever info I can, I hope it will be enough for you to diagnose the trouble.

    ***************FILE*****************

    import java.util.*;

    class Hello{
    public static void main(String[] args)
    {
    System.out.println("\nHello World\n");
    }

    }

    ****************************************

    jsparrow@BlackPearl:~> java Hello
    Exception in thread "main" java.lang.NoClassDefFoundError: Hello
    at gnu.java.lang.MainThread.run (libgcj.so.7)
    Caused by: java.lang.ClassNotFoundException: Hello not found in gnu.gcj.runtime.SystemClassLoader{urls=[], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
    at java.net.URLClassLoader.findClass (libgcj.so.7)
    at java.lang.ClassLoader.loadClass (libgcj.so.7)
    at java.lang.ClassLoader.loadClass (libgcj.so.7)
    at java.lang.Class.forName (libgcj.so.7)
    at gnu.java.lang.MainThread.run (libgcj.so.7)

    *******************************************

    /etc/java/java.conf

    # System-wide Java configuration file -*- sh -*-
    #
    # JPackage Project <http://www.jpackage.org/>
    # Location of jar files on the system
    JAVA_LIBDIR=/usr/share/java
    # Location of arch-specific jar files on the system
    JNI_LIBDIR=/usr/lib/java
    # Root of all native JVM installations
    JVM_ROOT=/usr/lib/jvm
    # You can define a system-wide JVM root here if you're not using the
    # default one
    #JAVA_HOME=$JVM_ROOT/java_bea
    # Options to pass to the java interpreter
    JAVACMD_OPTS=

    *****************************************

    I tried echo $path and get a blank line following the command. (as output)

    I tried to do this

    java -cp set CLASSPATH=. Hello

    only to get the same error.

    I'm almost at my wit's end and would really appreciate a solution

    I don't think this is necessary, but I run Suse on my notebook, IBM z60, Pentium M 1.73 with 512 MB RAM. Dual boot with Windows Xp.

  2. #2
    Linux Newbie DeoXMAN's Avatar
    Join Date
    Jul 2005
    Location
    Azerbaijan, Germany
    Posts
    154
    try to do
    which java
    and
    java -version
    and see what you get. so, be sure that java that you are running is version that you installed. if not, then see that is $PATH variable of bash shell, and put path to jdk6 to the beginning of $PATH
    Karabakh - I will be back

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    3
    Hi DeoXMAN,

    I do think you've got a point there and I think that's where the problem is, but I still can't seem to get it fixed.

    for instance

    which java

    gives me '/usr/bin/java' when in fact it ought to be '/usr/java/jdk1.6.0'

    and

    java -version says java 1.4.2 when I know I've got java 1.6.0 running on the sdk.

    So I tried set $path='/usr/java/jdk1.6.0/.'
    but still nothing.

    echo $path, still gives me a blank line after I input the command.

  4. #4
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,621
    Might I suggest installing Java 1.5.0 through Yast? Is there any reason you need 6 specifically? If you install 5 through Yast, everything will be handled for you.

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  5. #5
    Just Joined!
    Join Date
    Jan 2007
    Posts
    3
    Hi Bryan,

    Actually I finally figured out what to do. The trouble was with my environment variables. At first I couldn't figure out what to do because all my 'export' commands didn't seem to have any effect.

    Anyway the trick is to modify the .bashrc file which is on the home directory and set your persistent variable values there. It works fine then.

    I think all this arose coz I have both java 1.4(courtesy gnu) and then dloaded the latest sdk.(no specific reason, I didn't have an sdk went to the java site and dloaded the latest Lol).

    As for YaST that's another problem I've been having. You see I can only connect to the net using my PCMCIA card, and that isn't detected by my Linux set up. So everytime I need to dload something I have to go online through windows, and then access my windows drive from Linux. A pain, but I have no choice. Otherwise I need to make a LAN with somebody else and connect, and I still haven't figured out how to set up a proxy on YaST. That caused me quite a bit of grief too, and I had to take the long way around.

    Thanks for your time.

  6. #6
    Just Joined!
    Join Date
    Jan 2007
    Posts
    17
    I have the same problem, I have the latest java and javac files, but
    Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: Main
    when im trying to run compiled file.

  7. #7
    Just Joined!
    Join Date
    Jan 2007
    Posts
    17
    Sorry, installing JRE6 helped.

  8. #8
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,621
    Quote Originally Posted by Jack Sparrow
    As for YaST that's another problem I've been having. You see I can only connect to the net using my PCMCIA card, and that isn't detected by my Linux set up. So everytime I need to dload something I have to go online through windows, and then access my windows drive from Linux. A pain, but I have no choice. Otherwise I need to make a LAN with somebody else and connect, and I still haven't figured out how to set up a proxy on YaST. That caused me quite a bit of grief too, and I had to take the long way around.

    Thanks for your time.
    Glad you got it handled. As for the jdk/jre, they're on the non-oss cd which includes (among others) java 5, acrobat 7, realplayer, flash 7 and wireless drivers. You should take a look at it.

    As for the PCMCIA card, we'll gladly help with that. If you want, start another thread with some relevant info (make, model, error messages...) and someone will come along .

    Bryan
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...