Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
I wasnt sure if this should go into the programming thread, but im sure its more fitting for an installation/newbie question. Im running mandrake 9.1 (old i know, but for ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Sep 2003
    Location
    Brisbane, Australia
    Posts
    123

    Installing Java software development kit


    I wasnt sure if this should go into the programming thread, but im sure its more fitting for an installation/newbie question.

    Im running mandrake 9.1 (old i know, but for some reason the iso's i downloaded twice wouldnt boot from CD and also failed burning when i used nero 6 from windows. So i gave up after 6 useless disks now sitting around as coasters.

    Relevent information:
    What im questioning is, how do i compile a *.java document after i have created one? I thought i may just be able to go to terminal and type 'javac test.java' (for a file named 'test.java' and that would compile it, or atleast give a failure (for bad coding) but it says that the command is unrecognized. (in the usual non-existant command way)

    Im just wondering in that case have i either installed it wrong, or perhaps i should use an actual java compiler? Or perhaps there is another compiler command i should use instead?

    Thanks in advance for any help!
    /skythra

  2. #2
    Just Joined!
    Join Date
    Mar 2004
    Location
    Loda, IL
    Posts
    32
    I suggest 2 possibilities. One: javac is not in your path, therefore the shell can't find it. Update ld.so.config to include the path to javac. Two: just type in the entire path to javac when you use it, and forget about updating ld.so.config.

  3. #3
    Linux Newbie
    Join Date
    Aug 2001
    Location
    USA, Texas
    Posts
    217
    your $PATH is definately your problem. You need to find the full path to the java bin directory ... maybe /usr/share/j2sdk1.4.2/bin ( I just spoke to someone about this on irc earlier today ... may have been you ... I don't know) ... anyway ...

    lets assume that your path to your java executables is as stated above ...

    at a shell prompt type:
    Code:
    export PATH=$PATH:/usr/share/j2sdk1.4.2/bin
    then try executing javac and/or which javac. If you are successful in running javac then you need to add it to your path perminantly.

    If you are only concerned with using java as the one user then you can modify your ~/.bash_profile. Find the line like: PATH=/bin:/usr/bin/: .... and append :/usr/share/j2sdk1.4.2/bin to the end.

    If you want to add it to the path of every uses, then you should do the same thing as above except on /etc/profile instead of ~/.bash_profile
    [ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
    /* Don\'t make me use it! */

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Sep 2003
    Location
    Brisbane, Australia
    Posts
    123
    Thank you for the help.

    Edit: And for your information i need the compiler. =D Its about all i really need. Im in my sixth week into the course and i still havnt got the thing working. Im still making sure the install is right i think i left out a couple of things and then ill start working out the paths etc.

    Edit2: The path code seems to be a big hit, i havnt had the chance to do a test compile, but it now recognizes the various commands. Thanks alot the help is muchly appreciated. Now just to solve the following programming problems!
    /skythra

  6. #5
    Linux Newbie
    Join Date
    Sep 2003
    Location
    Brisbane, Australia
    Posts
    123
    Now im testing the code right, and im doing a basic example, im wondering if this error means im missing something in the installation, or have i just made a mistake in the code?

    Error:
    Code:
    [skythra@STUDY Documents]$ javac Convert.java
    [skythra@STUDY Documents]$ java Convert.class
    Exception in thread "main" java.lang.NoClassDefFoundError: Convert/class
    [skythra@STUDY Documents]$
    The java file:
    Code:
    /*
    ** file:    Convert.java
    **
    ** created: dd/mm/yy
    **
    ** author:  Skythra
    */
    
    import TerminalIO.*;
    public class Convert {
    	KeyboardReader reader = new KeyboardReader();
    	ScreenWriter writer = new ScreenWriter();
    
    	double pascal;
    	double torr;
    
    	public void run() {
    		writer.print ("Enter pressure Torr: ");
    		torr = reader.readDouble();
    		pascal = (torr*133.3224);
    		writer.print ("The equivalent in pascal is: ");
    		writer.println (pascal);
    		reader.pause();
    	}
     public static void main (String [] args) {
    	Convert tpo = new Convert();
    	tpo.run();
     }
    }
    Again, all help is appreciated.
    /skythra

  7. #6
    Linux Newbie
    Join Date
    Sep 2003
    Location
    Brisbane, Australia
    Posts
    123
    Just a note that i have tested this with over 10 different class files and none of them work. All have the same error: if you think you know what it causing this, please reply!

    I assume that java just cant understand the class but i dont know why!
    /skythra

  8. #7
    Linux Newbie
    Join Date
    Aug 2001
    Location
    USA, Texas
    Posts
    217
    Skythra, I think that your only problem is that you are using the class file with the .class extention.

    instead of: java Convert.class
    do: java Convert

    see if that works for ya.
    [ [ SykkN alloc ] initWithThePowerTo: destroyYouAll ];
    /* Don\'t make me use it! */

  9. #8
    Linux Newbie
    Join Date
    Sep 2003
    Location
    Brisbane, Australia
    Posts
    123
    I feel so stupid right now.

    So very stupid. I assumed... anyway. Next question! Thanks for that =D

    I know this was explained in the above post where sykkn carefully told me how to perminantly add the commands for the java code... but i didnt really quite understand. All i know is im supposed to at a point in my bash profile which looks like:
    Code:
    # /etc/profile -*- Mode: shell-script -*-
    # &#40;c&#41; MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>
    
    loginsh=1
    
    # Users generally won't see annoyng core files
    &#91; "$UID" = "0" &#93; && ulimit -S -c 1000000 > /dev/null 2>&1
    
    if ! echo $&#123;PATH&#125; |grep -q /usr/X11R6/bin ; then
        PATH="$PATH&#58;/usr/X11R6/bin" PATH="$PATH&#58;/usr/share/j2sdk1.4.2/bin"
    fi
    
    if &#91; "$UID" -ge 500 &#93; && ! echo $&#123;PATH&#125; |grep -q /usr/games ; then
        export PATH=$PATH&#58;/usr/games
    fi
    
    umask 022
    
    USER=`id -un`
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
    HISTCONTROL=ignoredups
    HOSTNAME=`/bin/hostname`
    HISTSIZE=1000
    
    if &#91; -z "$INPUTRC" -a ! -f "$HOME/.inputrc" &#93;; then
        INPUTRC=/etc/inputrc
    fi
    
    # some old programs still use it &#40;eg&#58; "man"&#41;, and it is also
    # required for level1 compliance for LI18NUX2000
    NLSPATH=/usr/share/locale/%l/%N
    
    export PATH PS1 USER LOGNAME MAIL HOSTNAME INPUTRC NLSPATH
    export HISTCONTROL HISTSIZE
    
    for i in /etc/profile.d/*.sh ; do
    	if &#91; -x $i &#93;; then
    		. $i
    	fi
    done
    
    unset i
    and im suppposed to add the line
    :/usr/share/j2sdk1.4.2/bin
    but all i managed to do was make mandrake unbootable into the skythra profile.... *cough*
    if anyone has time would they mind just giving me an example? Im not really very good at what i dont understand... sorry *_*
    /skythra

  10. #9
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284
    So it will look like this:

    # /etc/profile -*- Mode: shell-script -*-
    # (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>

    loginsh=1

    # Users generally won't see annoyng core files
    [ "$UID" = "0" ] && ulimit -S -c 1000000 > /dev/null 2>&1

    if ! echo ${PATH} |grep -q /usr/X11R6/bin ; then
    PATH="$PATH:/usr/X11R6/bin" PATH="$PATH:/usr/share/j2sdk1.4.2/bin"
    fi

    if [ "$UID" -ge 500 ] && ! echo ${PATH} |grep -q /usr/games ; then
    export PATH=$PATH:/usr/games
    fi


    export PATH=$PATH:/usr/share/j2sdk1.4.2/bin


    umask 022

    USER=`id -un`
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
    HISTCONTROL=ignoredups
    HOSTNAME=`/bin/hostname`
    HISTSIZE=1000

    if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
    INPUTRC=/etc/inputrc
    fi

    # some old programs still use it (eg: "man"), and it is also
    # required for level1 compliance for LI18NUX2000
    NLSPATH=/usr/share/locale/%l/%N

    export PATH PS1 USER LOGNAME MAIL HOSTNAME INPUTRC NLSPATH
    export HISTCONTROL HISTSIZE

    for i in /etc/profile.d/*.sh ; do
    if [ -x $i ]; then
    . $i
    fi
    done

    unset i
    Jason

  11. #10
    Linux Newbie
    Join Date
    Sep 2003
    Location
    Brisbane, Australia
    Posts
    123
    e_e;; thanks mate, that looks really self explanitory now that you have said it...

    And that will would with other things aswell? like say mozilla if i just tacked in the "export path=$path usr/local/mozilla/bin" then that would allow me to use the commands from the mozilla bin folder anywhere?

    Thanks for all the help, its really helped me understand alot on how the entire system seems to work =D
    /skythra

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
  •