Installing Java on a Macbook

Discussion in 'Mac Programming' started by happyElephant, Nov 17, 2006.

  1. happyElephant macrumors member

    Joined:
    Oct 27, 2006
    #1
    Hi,
    I've been trying to install Java J2SE 5.0 version on my Macbook and I'm not sure if I did it right. For learning Java programming I use BlueJ at the beginning which requires JDK/JRE. This time BlueJ doesn't work(buttons aren't active). Having in mind that it worked on a PowerBookG4 where I have previously installed Java, I'm supposing that most likely the installation wasn't right this time. How do I double-check Java installation? or maybe reinstall it ?
    thanks for suggestions
     
  2. Lyle macrumors 68000

    Lyle

    Joined:
    Jun 11, 2003
    Location:
    Madison, Alabama
    #2
    You can check to see which version of Java is installed by opening a Terminal window (Applications -> Utilities -> Terminal) and typing "java -version" at the command prompt. If you have Java 5 installed, it should report something like this:
    I'm not familiar with BlueJ so I can't offer any advice on that problem. You should check the BlueJ web site (if you haven't already) to see if there are any solutions to this problem.
     
  3. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #3
    You should have the Java-Runtime installed on your Mac when you bought it, to get the JDK (Java development kit), you need to sign up for an apple developer account (http://connect.apple.com), and login to this site, then click on Java on the right hand side and download the appropriate software.
     
  4. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #4
    You almost undoutedly already have Java 5 installed.

    If you open Terminal and type
    Code:
    ls -l /System/Library/Frameworks/JavaVM.framework/Versions/
    you should see all the installed versions. CurrentJDK will point to the one currently in use.
     
  5. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #5
    Thanks. I appreciate your advises.
    Now let`s take a look at my Terminator window:
    total 48
    lrwxr-xr-x 1 root wheel 5 Nov 17 19:16 1.3 -> 1.3.1
    drwxr-xr-x 8 root wheel 272 Apr 18 2006 1.3.1
    lrwxr-xr-x 1 root wheel 5 Apr 18 2006 1.4 -> 1.4.2
    drwxr-xr-x 8 root wheel 272 Apr 18 2006 1.4.2
    lrwxr-xr-x 1 root wheel 5 Nov 16 21:51 1.5 -> 1.5.0
    drwxr-xr-x 8 root wheel 272 Apr 18 2006 1.5.0
    lrwxr-xr-x 1 root wheel 5 Nov 17 19:16 1.6 -> 1.6.0
    drwxr-xr-x 8 root wheel 272 Nov 17 19:16 1.6.0
    drwxr-xr-x 6 root wheel 204 Nov 17 19:16 A
    lrwxr-xr-x 1 root wheel 1 Nov 16 21:51 Current -> A
    lrwxr-xr-x 1 root wheel 3 Nov 17 19:16 CurrentJDK -> 1.5
    [Process completed]


    What does it mean?



    I've registered with Apple's Developper Connection looking for the missing part of my Java appl. There I've found some phrase which I'm not sure I undrstand: "The preview is not removable and should not be installed on systems with critical data. "
    a) What is the function of Preview? and
    b)What is ment by "critical data"?
     
  6. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #6
    This shows you have the current JDK installed.

    You have a Macbook so don't want that preview as it's only for Mac OS X 10.3.x

    EDIT: Download and unzip the attached Java file, save it in your home directory.

    Then load terminal and type,
    Code:
    javac Test.java
    
    Once that's finished type
    Code:
    java Test
    
    It should then display "Hello World"
     

    Attached Files:

  7. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #7

    The first command result is:
    "error: cannot read: Test.java
    1 error
    [Process exited - exit code 1]"


    The second:
    "

    javac: invalid flag: Test
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are used
    -classpath <path> Specify where to find user class files
    -cp <path> Specify where to find user class files
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -endorseddirs <dirs> Override location of endorsed standards path
    -d <directory> Specify where to place generated class files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -version Version information
    -help Print a synopsis of standard options
    -X Print a synopsis of nonstandard options
    -J<flag> Pass <flag> directly to the runtime system

    [Process exited - exit code 2]"


    Well, any good news:) ?
     
  8. jsw Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #8
    First, you likely didn't download (or move) Test.java to your home directory (as opposed to your desktop), so the Java compiler can't find it. Try dragging the file to the home-shaped icon on your Finder window sidebar, then try again.

    Second, I believe you typed 'javac' instead of 'java' for the second command, but, since you didn't compile the app with the first command, the second wouldn't have worked anyway.
     
  9. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #9
    HappyElephant, please try the following commands in "Terminator" and capture the entire window contents of the responses.

    cd /usr/bin
    ls -ltr java*

    cd /usr/sbin
    ls-ltr java*

    Also, it looks like you have installed Mustang (Java6), any particular reason?
     
  10. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #10
    I was really fast finding my home directory icon(only half an hour spent:):
    Now the output is :
    "Hello World!
    [Process completed]"


    :)


    BlueJ is not active though.
     
  11. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #11
    Commands in terminator results in:
    "ls -ltr java*
    lrwxr-xr-x 1 root wheel 85 Nov 16 21:51 java-rmi.cgi -> /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java-rmi.cgi
    lrwxr-xr-x 1 root wheel 76 Nov 17 19:16 javaws -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaws
    lrwxr-xr-x 1 root wheel 75 Nov 17 19:16 javap -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javap
    lrwxr-xr-x 1 root wheel 75 Nov 17 19:16 javah -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javah
    lrwxr-xr-x 1 root wheel 77 Nov 17 19:16 javadoc -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javadoc
    lrwxr-xr-x 1 root wheel 75 Nov 17 19:16 javac -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac
    lrwxr-xr-x 1 root wheel 74 Nov 17 19:16 java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java"


    No, no particular reason for installing Mustang. I considered it to be "the latest version". Wasn't I supposed to do this?
    P.S.: I'm amazed by the amount of things I'm learning in this forum.
     
  12. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #12
    you don't need Mustang to run anything yet, and since its not official I wouldn't recommend installing it unless you know what you are doing. That said, you DID NOTHING WRONG.

    Two more terminator commands please (copy and paste).

    ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java*

    ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java*

    PS. If you are wondering why, I am just checking that all of your symlinks are pointing at the appropriate java version.
     
  13. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #13
    Output:
    "Last login: Fri Nov 17 22:20:43 on ttyp2
    Welcome to Darwin!
    myName-computer:~ myName$ ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/Current/java*
    ls: /System/Library/Frameworks/JavaVM.framework/Versions/Current/java*: No such file or directory
    myName-computer:~ myName$
    myName-computer:~ myName$ ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/java*
    ls: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/java*: No such file or directory
    myName-computer:~ myName$ "



    "No such file or directory" output gives me a feeling of something to be fixed...


    P.S;
    I've replased user's name by "myName"
     
  14. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #14
    :eek: :eek: :eek:

    Sorry, I meant

    ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java*

    ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java*
     
  15. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #15

    Better looking output this time :)


    ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java*

    ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java*
    __________________myName-computer:~ myName$ ls -ltr /System/LibraVM.framework/Versions/Current/Commands/java*
    -rwxr-xr-x 1 root wheel 34992 Sep 5 19:42 /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
    -rwxr-xr-x 1 root wheel 34992 Sep 5 19:42 /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac
    -rwxr-xr-x 1 root wheel 34992 Sep 5 19:42 /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javadoc
    -rwxr-xr-x 1 root wheel 34992 Sep 5 19:42 /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javah
    -rwxr-xr-x 1 root wheel 34992 Sep 5 19:42 /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javap
    -rwxr-xr-x 1 root wheel 34992 Sep 5 19:42 /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaws
    myName-computer:~ myName$
    myName-computer:~ myName$ ls -ltr /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java*
    -rwxr-xr-x 1 root wheel 109944 Mar 22 2006 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/javap
    -rwxr-xr-x 1 root wheel 109944 Mar 22 2006 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/javah
    -rwxr-xr-x 1 root wheel 109944 Mar 22 2006 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/javadoc
    -rwxr-xr-x 1 root wheel 109944 Mar 22 2006 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/javac
    -rwxr-xr-x 1 root wheel 2126 Mar 22 2006 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java-rmi.cgi
    -rwxr-xr-x 1 root wheel 109944 Mar 22 2006 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/java
    lrwxr-xr-x 1 root wheel 92 Nov 16 21:51 /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Commands/javaws -> /Applications/Utilities/Java/J2SE 5.0/Java Cache Viewer.app/Contents/MacOS/Java Cache Viewer...


    So what would your opinion be about this output?
     
  16. jeremy.king macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #16
    I was expecting these to be symlinks (think shortcut) to the 1.5 version, not executables. I'll have to check my setup at home.

    Did you ever run

    java -version

    in "Terminator"?

    What I was suspecting is that when I upgraded to Java5, not all of my symlinks were updated properly, so my javac command was pointing at version 5 and my java command was pointing at version 4, so everything was screwy and throwing exceptions and all the jazz.

    So what exact issue are you having with BlueJ? Does it launch and you can't do anything, or does it fail to launch? Any exceptions?
     
  17. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #17
    Terminator is Terminal (see attached pic) right?
    Picture 8.png
    God I'm getting confused. :eek:.

    BlueJ works on my iMac G5, (I would test on my Macbook but Apple are repairing it currently.), maybe it's got a preferences error. Try dragging the folder org.bluej and the file org.bluej.BlueJ.plist from ~/Library/Preferences to the desktop. (where ~/ represents your home directory which is where I got you to put Test.java earlier.)

    EDIT: I tried BlueJ 2.1.3
     
  18. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #18

    No, I've never run java version in Terminator before.

    Just can't believe :I'm able to launch it( both of them netbeans bluej 5.0 and bluej) however here're the comments:


    Trying to override old definition of task java
    Compiling 1 source file to /Users/myName/EmptyBluej
    /Users/myName/EmptyBluej/NewAbstract.java:3: class RemoveDuplicates is public, should be declared in a file named RemoveDuplicates.java
    public class RemoveDuplicates {
    /Users/myName/EmptyBluej/NewAbstract.java:6: cannot find symbol
    symbol : class Set
    location: class RemoveDuplicates
    Set<Integer> set = new LinkedHashSet<Integer>();
    /Users/myName/EmptyBluej/NewAbstract.java:6: cannot find symbol
    symbol : class LinkedHashSet
    location: class RemoveDuplicates
    Set<Integer> set = new LinkedHashSet<Integer>();
    3 errors
    /Users/myName/EmptyBluej/nbproject/build-impl.xml:293: The following error occurred while executing this line:
    /Users/myName/EmptyBluej/nbproject/build-impl.xml:142: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 4 seconds)



    and the"hello world"test:

    Trying to override old definition of task java
    Compiling 1 source file to /Users/myName/EmptyBluej
    /Users/myName/EmptyBluej/NewAbstract.java:3: class Test is public, should be declared in a file named Test.java
    public class Test {
    1 error
    /Users/myName/EmptyBluej/nbproject/build-impl.xml:293: The following error occurred while executing this line:
    /Users/myName/EmptyBluej/nbproject/build-impl.xml:142: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 10 seconds)

    Why would the problem be in simple words, please
     
  19. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #19
    Hey, you're making fun of me now(attaching the icons:) just because it took me a little more ( only half an hour) of time in order to find my home dir icon. It's because of fatigue

    Finally, I've launched NetBeans BlueJ and bluej(big thanks to Lyle who indicated me the blueJ site).

    I'm trying to figure out what the compiler's problem is for the moment...
     
  20. LtRammstein macrumors 6502a

    LtRammstein

    Joined:
    Jun 20, 2006
    Location:
    Denver, CO
    #20
    BlueJ, after seeing what's going on (and I've used BlueJ before for a class [COSC 1010]).

    BlueJ is a complete Java application, that's why it takes so long to run projects and classes and whatnot on it.

    If it refuses to open, I recommend DELETING ALL BLUEJ FILES and REINSTALLING BLUEJ.

    One, some files they release could be bad with the new Java update (remember BlueJ doesn't have the insight into Sun's Java). Since they released the new update, BlueJ would have an update of it in about two days or so.

    If that doesn't work, it could be that the Java environment on your MacBook could be screwing something up.
     
  21. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #21
    I'm really not, when doing something difficult, I find step by step instructions very useful, if something is named incorrectly, then it is more difficult for anyone later browsing the thread who also wants help. I'm not trying to make fun, it is probably possible to use another terminal like application, (or for 'terminator' to be a UNIX program accessed from the command line)

    I didn't notice, I don't generally use the thread subscribe option, just come back later to thread's I've posted on.;)


    I think it could be a preferences issue for BlueJ, it might have lost the correct compiler locations, have you tried that?

     
  22. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #22
     
  23. happyElephant thread starter macrumors member

    Joined:
    Oct 27, 2006
    #23
    I've followed this advise- it didn't work though... So I kept working on my other computer.
    Today again I've been trying to make the compiler (NetBeans 5.0BlueJ) work.
    Everytime I end up getting the message:" Trying to override old definition of task java". What does it mean?
     

Share This Page