Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
Hi, I am having way too much trouble getting java jdk to work on my linux box. I've installed java many times before and never had this problem. I don't ...
  1. #1
    Just Joined!
    Join Date
    Oct 2004
    Posts
    42

    JAVA jdk problem

    Hi, I am having way too much trouble getting java jdk to work on my linux box. I've installed java many times before and never had this problem. I don't know what is going on. I am currently using ubuntu breezy release.. I hope that isn't a problem. I know this is debian. I'm pretty sure ubuntu is somewhat like debian. Here is the info I think you'll need to know......

    1) Downloaded jdk-1.5.0-linux.bin from the java.sun.com website.
    2) Opened up a terminal and typed:
    sh jdk-1.5.0-linux.bin
    3) This extracted the file into the current directory. I had the file placed in the directory:
    /usr/java
    So, the directory of the java jdk is now:
    /usr/java/jdk-1.5.0
    4) Set the JAVA_HOME variable:
    JAVA_HOME=/usr/java/jdk1.5.0
    5) Set the PATH variable:
    PATH=$JAVA_HOME/bin:$PATH
    Also, I exported it....
    6) Everything seems to be fine from here. When I do a java -version it detects it fine. So my PATH variable is working fine:
    nate@ubuntu:/$ java -version
    java version "1.5.0_05"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
    Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)

    7) Now when I try to compile a program or when I try to extract a jar file I get error messages:
    -somtimes this...
    Exception in thread "main" java.lang.NoClassDefFoundError:
    -somtimes this...
    Exception in thread "main" java.lang.NoSuchMethodError: main


    I don't get it fellas... It should work, shouldn't it.... I really hope there is something I'm overlooking here. Thanks in advance if there is any way you can help me out... I need to have jdk working and installed on my linux.... Otherwise I need to revert back to windows.... ack....

    Thanks,
    _nate

  2. #2
    Linux Guru AlexK's Avatar
    Join Date
    Feb 2005
    Location
    Earth
    Posts
    3,379
    i used to have this problem in suse, turns out I was using int main (String[] args) instead of void main ... (C programmer here)

    it could also be due to an improperly installed jdk (similar error when i installed it a loong time ago). Is it possible for you to use apt to get jdk? or java_<version_number>_devel?

    Hope this helps a bit.
    Life is complex, it has a real part and an imaginary part.

  3. #3
    Just Joined!
    Join Date
    Oct 2004
    Posts
    42
    Nah, I downloaded the jdk straight from the java.sun.com website.... The only thing I can think of is that ubuntu came with a version of java that I uninstalled... Maybe that somehow screwed somthing up... I don't see how it could have though.

  4. #4
    Linux Guru AlexK's Avatar
    Join Date
    Feb 2005
    Location
    Earth
    Posts
    3,379
    the download might have been fine, but the way it is installed could have caused some inconsistencies. I downloaded jdk_1.5 from sun like a few months ago and installed it just fine, thing is that it gave similar errors to what you are getting. However, when i uninstalled that and used official SuSE versions (but jdk 1.4, I found SuSE versions of 1.5 a few weeks ago and those installed and worked fine) everything worked perfectly.

    I am not sure if jdk is available via apt for debian/ubuntu users, but it most likely will be. So, what i suggest you do now is uninstall the jdk you downloaded from sun and try installing via apt, perhaps it won't give those errors.

    just do:
    Code:
    apt search jdk
    or
    apt search java*devel*
    Life is complex, it has a real part and an imaginary part.

  5. #5
    Just Joined!
    Join Date
    Oct 2004
    Posts
    42
    I've tried to get it from apt and have been unable to locate a package. They offer the open sourced packages but that is not what I need. I did a little google searching and found this:

    If you want to install the Java compiler as well as the runtime environment, the easiest thing to do is to [WWW] get it directly from Sun. Take care to use the "Linux self-extracting file" version. Converting the RPM with alien will not work.

    Then follow the instructions as set forth on JavaPackageBuildNewVersions to create a .deb file you can install using dpkg.
    Do I really need to make a deb out of it? Shouldn't it be alright if I just extract it and such? Thanks for the help btw....

  6. #6
    Linux Guru AlexK's Avatar
    Join Date
    Feb 2005
    Location
    Earth
    Posts
    3,379
    From google, i this regarding the installation of jdk on ubuntu. Apparaently, the packages are available but on a different apt repository of sorts (from what i can understand).

    Again from google is this suggestion on repackaging sun installer for ubuntu.

    From googling, it appears that you may need to repackage the installer to *.deb and install that way. Perhaps some other people on these forums who have more experience than I with debian and this matter can be of more help.

    Hope this helps.
    Life is complex, it has a real part and an imaginary part.

  7. #7
    Just Joined!
    Join Date
    Oct 2004
    Posts
    42
    Thanks... It's rather pathetic that I need someone else to do my googling for me.. Sorry about that... I guess I was searching too broad of java problems... I didn't think it was a ubuntu specific sort of thing...

    I created a .deb package and it now does work... I can compile and run java programs... Only problem is that the -jar option still does not work... I get this...
    Code:
    nate@ubuntu&#58;~$ java -jar /home/nate/Desktop/Azureus2.3.0.4.jar
    Exception in thread "main" java.lang.NoClassDefFoundError&#58; org/apache/commons/cli/CommandLine
    I'll look at some of the following links you provided and do some more ubuntu specific searches for help... I appreciate your help though...

    Thanks,
    _nate

  8. #8
    Just Joined!
    Join Date
    Oct 2005
    Posts
    1

    Java Problems............

    I have the exact same problem I tried the streamline method
    suggested at http://wiki.osuosl.org/display/DEV/Java+on+Debian
    and the ubuntu wikki method:


    * Grab: http://java.sun.com/j2se/1.5.0/download.jsp
    * apt-get install java-package fakeroot
    * fakeroot make-jpkg jre-1_5_0_02-linux-i586.bin
    * dpkg -i sun-j2re1.5_1.5.0+update02_i386.deb
    * logout and login again and check java
    * java -version



    The first I installed it this way it worked great but when I had to re-install ubuntu again (New Harddrive) went to a java sight to test failed I tried posting on the ubuntu forum. I used the latest JRE Tarball and followed
    the instructions.


    Liquidheat

  9. #9
    Linux Guru Vergil83's Avatar
    Join Date
    Mar 2004
    Posts
    2,408
    I don't know if this will work for ubuntu but in debian I just add
    Code:
    deb ftp&#58;//ftp.tux.org/java/debian/ sid non-free
    to your
    Code:
    /etc/apt/sources.list
    then
    Code:
    apt-get update
    apt-get install j2re1.4
    Brilliant Mediocrity - Making Failure Look Good

  10. #10
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401

    CLASSPATH

    You haven't set the CLASSPATH enviroment variable, wich is used to locate class files.
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

Page 1 of 2 1 2 LastLast

Posting Permissions

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