Results 1 to 3 of 3
  1. #1
    Konan is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Java on OSX Mountain Lion - isn't installed normally.

    Didn't see an install problems forum.

    I hope to be able to ask this newbie question in a manner that it can be understood.

    Hardware. Apple Mac Mini 16gb OSX 10.8.3 (Mountain Lion)

    I installed the Netbeans with JDK package (jdk-7u21-nb-7_3-macosx-x64.dmg) which went on easy and works fine. I have been banging out newbie "Hello World's" for a couple of days. Lots of fun, even, especially after a career of Perl and C.

    But, when I build and clean a working program to get a .jar file and try to run it from the command line, I get...

    Mac-mini:dist pgmosx$ ./SourceReader.jar
    ./SourceReader.jar: line 1: PK: command not found
    ./SourceReader.jar: line 2:.??B: command not found
    ./SourceReader.jar: line 3:-??Bw????META-INF/MANIFEST.MFManifest-Version:: No such file or directory
    ./SourceReader.jar: line 4: Ant-Version:: command not found
    ./SourceReader.jar: line 5: syntax error near unexpected token `('
    '/SourceReader.jar: line 5: `Created-By: 1.7.0_21-b12 (Oracle Corporation)

    Using the README method of java -jar "SourceReader.jar" I get...

    -bash: java: command not found

    That is correct, because the command "which java" gives nothing and there is no /usr/java subdirectory.

    NONETHELESS, java is SOMEWHERE on the machine. The Oracle notes say that the JDK installs the JRE. Using the command in their install notes...

    /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version

    gives...

    java version "1.7.0_21"
    Java(TM) SE Runtime Environment (build 1.7.0_21-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

    so it's on there somewhere.

    Time passes...

    I finally discovered that java is in the Applications/Netbeans.app folder in the package contents - in other words, packaged with Netbeans. But, so far no amount of bashing in my .bash_profile has managed to point a session to it. I assume that I could just download another JRE from Oracle and install it in the normal place, but Apple doesn't like Java now and takes it off on every new update. There is a note from Oracle that says that only one JRE is allowed on a single machine at a time. I would hate to hose the machine - on my 1mb network, it would take a day or so to reload it.

    I probably just need to step back for a day or so and hit it again because I am probably just not seeing the forest for the trees.

    However...

    Any OSX users out there that have installed the combined Netbeans/JDK package and got it working from a command line?

    Thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,663
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java on OSX Mountain Lion - isn't installed normally.

    Make your 'path' environment variable point to the directory where the 'java' executable file is stored; you can type 'java ...' from any directory afterwards. Simply typing the name of a .jar file makes bash think it's a bash script (no magic number in that file that tells it to think otherwise) and so it chokes on it. Type 'java -jar ./SourceReader.jar' in the directory where that .jar file is stored. I don't know how you can make a 'file association' on OSX, maybe that's just an MS Windows thingy ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Konan is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Re: Java on OSX Mountain Lion - isn't installed normally.

    Thanks.

    However, OSX applications of any size are contained inside of a package that appears as one file to the file system. That allow it to be updated or removed without having to chase files down that might be scattered all over the system. Apparently, the Unix path can't see inside of the package.

    So... I installed the jre from Oracle and it installed fine without clobbering Netbeans. I ran the test applet at Oracle and it gave me the green light that the jre is installed successfully. Of course, that is an applet in the browser and I want standalone java.

    The javac compiler even works from the commandline. However, there is still no java runtime that I can find anywhere. Apple's search Spotlight can't find one. I even wrote a perl script (sorry, everyone) to search the entire drive for any file starting with java... None. The jre install put all the other parts into the proper place in /usr/bin, such as jar jarsigner javac javaconfig javadoc javah javap javatool and javaws, but unless I am reading the man pages wrong, I am looking for an executable called just java. Not there.

    Question. Do the browser applets use the same java engine as a standalone program? If so, then it is really well hidden.

Similar Threads

  1. How to open port in OSX Lion?
    By Shellback3 in forum Networking
    Replies: 0
    Last Post: 07-19-2012, 09:08 PM
  2. Making an Applet in Mac Lion.
    By DaveAp7 in forum New To Java
    Replies: 2
    Last Post: 02-01-2012, 05:08 AM
  3. Java issue on Mac Lion
    By vrobic in forum New To Java
    Replies: 1
    Last Post: 11-07-2011, 02:25 PM
  4. How i installed Java EE
    By RichersooN in forum New To Java
    Replies: 8
    Last Post: 05-18-2011, 08:34 AM
  5. Replies: 0
    Last Post: 05-13-2011, 07:38 PM

Posting Permissions

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