Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macpeterr

macrumors newbie
Original poster
Jun 24, 2008
21
15
I recenlty bought Bruce Eckels book/pdf "Thinking in Java Fourth Edition" and The Annotated Solutions Guide code examples.
The installation instructions for the code examples are not written for OS X and that is where the trouble starts.. :D

First the CLASSPATH has to be set to the code examples directory.
I can add the CLASSPATH to the bashrc but decided to add the paths to the DefaultClassPath in /System/Library/Java/JavaConfig.plist

Then some jar files have to be copied to a created directory,
javassist.jar, swt.jar, tools.jar, javaws.jar, xom.jar, and added to the CLASSPATH.

So after this the DefaultClassPath looks like this:
Code:
        DefaultClasspath = "$HOME/Library/Java:$NEXT_ROOT/Library/Java:$NEXT_ROOT/System/Library/Java:$NEXT_ROOT/Network/Library/Java:$NEXT_ROOT/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar:$NEXT_ROOT/System/Library/Frameworks/JavaVM.framework/Classes/ui.jar:/Users/peter/Documents/Java\ training/TIJ4-Solutions-code:/Users/peter/Documents/Java\ training/jars/javassist.jar:/Users/peter/Documents/Java\ training/jars/javaws.jar:/Users/peter/Documents/Java\ training/jars/swt.jar:/Users/peter/Documents/Java\ training/jars/xom-1.1.jar";

Installing ant was easy, so building the code could start using ant...
But it fails

Code:
BUILD FAILED
/Users/peter/Documents/Java training/TIJ4-Solutions-code/build.xml:70: The following error occurred while executing this line:
/Users/peter/Documents/Java training/TIJ4-Solutions-code/net/build.xml:68: You must install the Javassist library from http://sourceforge.net/projects/jboss/

I installed the javassist jar file in the same directory as defined in DefaultClassPath so have no clue what is wrong. Hints / tips ??

Also tools.jar is not available in the JDK installed with OS X wherefore i have not found a workaround. Does somebody have a workaround for this ? Or better complete instructions for installing the code examples from Bruce Eckels Annotated Solution Guide for Thinking in Java. I cannot imagine that i am the first to install this on OS X, and googled ont his subject but have not been able to find any instructions.

Any help is welcome !
 
BUILD FAILED J2SE5 required

Thank you for the "Solutions for OSX", they were really helpful.

However, a new problem has come up as the versions have been updated.

The "build.xml" still checks for java version 1.5

I'm using Java version 1.6 and so it failed to build.
Code:
build:

BUILD FAILED C:\TIJ4\code\build.xml:59:J2SE5 required

Now apparently, a quick fix is to EDIT the build.xml file and change all the 1.5 to 1.6 so that it wont give an error and , presumably, build as if nothing is wrong.

I did that using textedit , "saved a version" , typed "ant build" in terminal (mac os lion) and it still failed to build.

In addition to changing 1.5 to 1.6 in 4 places in the xml file, I also misspelled the error message like so...
Code:
<fail message="J2SE5 rEEEEEEequired" unless="version1.6"/>
and then saved the file as build.xml.

And yet when the fail message came up, it was spelled correctly
Code:
<fail message="J2SE5 required" unless="version1.6"/>

Does this mean I have not saved the .xml file correctly and it's still using the previous ("version 1.5") xml file?

What else can I do? Is it using a previously installed version of java? like 1.3 without my knowledge?

This is terribly confusing for beginners. I feel like I need a full course in terminal commands, .xml, pico , CLASSPATH manipulation, before I can even get started!
 
BUILD FAILED J2SE5 required

Hi TheCodec,

The build.xml i have used does not check for java version 1.5 but for 'NOT (Java 1.1 | 1.2 | 1.3 | 1.4)'. The ''BUILD FAILED C:\TIJ4\code\build.xml:59:J2SE5 required" error is printed unless the following condition is met.

Code:
  <condition property="version1.5OrGreater">
    <not>
      <or>
        <equals arg1="${ant.java.version}" arg2="1.1"/>
        <equals arg1="${ant.java.version}" arg2="1.2"/>
        <equals arg1="${ant.java.version}" arg2="1.3"/>
        <equals arg1="${ant.java.version}" arg2="1.4"/>
      </or>
    </not>
  </condition>

Since the line number printed is 59 is assume that this is also the run target in your build.xml ? This target depends on the build target which compiles all build.xml files in the child projects/examples. So i think there occurs an error in the subant build.xml files which are called. Can you check the errors.txt file and see what is printed there ? I also checked some subant build.xml files but could not find odd code there.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.