WWDC2004 Session 318
Transcript
Kind: captions
Language: en
morning everyone this is session 318
using Xcode for Java development
please welcome Ted Jusuf ik Java
engineer let's see where's that clicker
so welcome to Xcode for Java development
Wednesday morning halfway through the
week rates get going so why are you here
um basically if you do Java development
on Mac OS 10 and you want to learn more
about the tools that we provide if you
want to know how Xcode can help you do
Java development and if you want to know
what's new and xcode for java
development those are the questions that
we're going to try and address at this
session so it's more specifically what
are we going to talk about well as you
know there's been lots of Xcode updates
we're going to talk about code
completion which is something new for
Java and Xcode we're also including ant
now with your Xcode distributions and so
we're going to be kind of going into
that it's a direction we're moving in
there's a application developer preview
that will allow you to do a lot of j2ee
development on your client machine we're
going to talk briefly about that and
then of course the java 142 update we're
also going to talk go into detail about
actually doing builds with Xcode and
Java and then also debugging and then
finalized with our 1.5 and talked about
what you need to do to actually do
development with that in Xcode because
it's not completely there yet but it's
it's very easy to get working so what is
Xcode actually this all should just be
review if by this point in the week you
don't know what Xcode is well we'll show
it to you but
so a C++ C Objective C AppleScript Java
IDE full Java debugger gdb integration
Apple script debugger include with every
Mac OS 10 updates available a course
from connect apple comm we are also
introducing this week preview so the 1.5
and 2.0 the 1.5 is for panther the 2.0
is for Tiger debuting will actually go
into a little bit of the differences a
little bit later on and like I said
earlier those are both available from
connect apple comm so at this point let
me bring up debuting and give them to
show you a demo of code sense thanks
good morning so code sense actually is
one of the big things new in Xcode this
year we've had code sense in some form
for quite some time the best support of
course has been an objective C and C++
but now we're bringing some new stuff
along to you Java developers so code
sense is actually a group of
technologies it's used for class
browsing we have a symbol smart group in
the main window there's a number of
navigation capabilities that are
provided by code sense and of course new
is code completion for Java so code
sense is based on indexing now indexing
has gotten a bad rap with Xcode for Java
for a little for a little while here
we've improved the speed quite a bit
indexing the system jdk jdk classes
about is about ten times faster than it
was in xcode 1.2 so you'll definitely
notice that speed difference and in fact
indexing of source files happens on
another thread not on the main thread so
it won't get in your way while you're
while you're editing your files it's
also important to know that code sense
is something that's used by the java
portion
of Xcode for the debugger and also for
the Jam based build system the debugger
uses it so that it can actually get the
correspondence between class files that
are running and the source files that
you're editing in the build system uses
it to get dependency information so that
it can speed up your build times so code
completion I think if you guys are Java
developers you've seen code completion
on a number of IDs it allows you to
automatically suggest a completion based
on the current context that you're
editing in in Xcode you can bring it up
on demand or you can have it
automatically come up you can have it
limit the list that comes up to only
those that match what you've typed so
far that's something that's a little
different from other IDE implementations
something that I personally like quite a
bit and when you insert method calls
it'll insert placeholder strings for
each of the arguments so as I said the
Java support for code completion is new
we actually had some completion there in
well one one and one two but it was
based on only the words in the current
file so a little helpful not quite what
you used to the preview is here at the
conference in both Xcode 1 5 and 2.0
there are some known limitations it's
not done yet
it's definitely preview it's actually a
little bit more stable in the one 5
release than it is in the 2.0 release
just because everything around it is a
little more stable so with that we still
want to know what you like and what you
don't like about it you're certainly
welcome to tell us about some of the
limitations you see while using it
although I swear we do know about some
of them it's not a surprise we know
we're not done with that I'm going to do
a little demonstration of code sense so
let's bring up Xcode here and just
create a new swing application let's see
a new project
and here we go okay there's one issue
here this is X code 1.2 so Ted did you
know that the X code 1.2 is on there can
we switch over to this machine I'll do a
demo on on Tiger it's a little less
stable here which is why I wanted to do
it on Panther but we'll go ahead and
bring up X codon and show this here new
project
yeah can you switch demo machines please
over to the demo one here sorry to
change my mind on you
okay so we have a new project here no
that's good at least you guys can see it
so there's the groups and file list over
here on the left stuff you've seen
before and a list of what's selected
shows up on the right in the detail view
the first thing I want to show you is
the project symbol smart group so a
smart group is something in Xcode that
gets its contents dynamically from from
the project itself in this case the the
project symbol smart group shows you the
symbols that are that have been indexed
in your project only the stuff in your
project it doesn't show anything that's
brought in from frameworks or from the
system JDK okay so we can go ahead and
bring up an editor here and you can
click around on it and of course take
you to the location you you're looking
for and you can filter so you can say oh
let's search for any symbol that has the
word about in it and it shows you that
all right away
another thing in Xcode is that you can
command double click on words in your
file to quickly navigate between them
now I come in double click there and of
course there are quite a few a few
classes that implement set resizable so
let's go ahead to the dialogue version
of that so this is something also that's
new in Xcode 1.5 and 2.0 we have the
system classes indexed for you but we
wouldn't show you any of their contents
so here we're showing you a dump of the
class file and you can you can move
around it it only shows you essentially
the api's it doesn't show you a dump of
the bytecode or decompile but it does
give you an idea of what api's are there
okay with that let's go ahead and bring
up the class browser for this project
takes a second there's actually quite a
lot of classes in here as you guys know
what's that oh there we go sorry about
that
so it's got all the JDK clap JDK classes
in here and you can click around between
them you can of course limit what you're
looking at so I only care about the
classes in this project I'm gonna close
this and then option click on the twisty
triangle and it shows all the classes in
your project in the hierarchy one nice
that's nice thing you can also look at
all the classes in a flat view this of
course takes a second I forget how many
thousands of classes there are here but
there's many many many and if we were to
click on one of those and wanted to see
where it appeared in the hierarchy I
don't know if this is a particularly
interesting one that I've clicked on but
one thing you can do is just switch back
to the hierarchy view and it'll keep
that selected it's down there at the
bottom so you can see that that guy
inherits from an action listener all
right let me let's go ahead and close up
the class browser well I'm gonna do a
little editing here but what I want to
do this is a standard swing application
we'll go ahead and run it just to show
you know it brings up the standard stuff
it's got a preference box which is kind
of boring quit out of that I'm gonna
change the preference box a little and
I'll show you code completion while I'm
doing that so let's just see what
symbols have to do with preferences and
they come up so the first thing I'll do
is preferences is the method in the in
the application that brings up the
Preferences box and I want to tell it to
change its font so I'm gonna say prefs
and if you hit option escape it'll bring
up a list for you of what's available
and it turns out that there it knows
about the instance variable press prefs
there which is of type pref pane and go
ahead and hit tab to complete that
how do you use that zoom feature
actually you know I can do something
almost as good let's go ahead and make
that a little bit bigger and the tech
sighs boy that is small isn't it that a
little better yeah sorry about that
okay so where was I preferences okay and
actually while I do this let's go ahead
into the preferences and show you
quickly under the navigation there's
options to automatically suggest I'm
going to turn on the automatically
suggest option here since that's
actually the way I work and I prefer it
that way
so as you start to type it'll underline
the text that you've typed in it says I
know that there's something that can be
completed and the underlying is that
clue that there's something there and
that it's ambiguous it doesn't know oh
what is next but if I type a little bit
more it says oh the only symbol that's
next that has an F after it also has an
O and you can bring up the list of
course and see so there's set focusable
and quite a few other routines there but
I'm going to do a set font and if I hit
tab and complete it it inserts a little
placeholder there that tells you the
type of the argument so I also know that
there's a font instance variable there
too and let's go ahead into the
preference pane itself and we need to
add a new method it turns out if you
just set the font on the pain that won't
affect the text inside it so we need to
go in there too so we'll just click on
one of those and start adding a new
method there so it knows public and just
continue on here we'll add set font and
type font and just give it an argument
named F
and for this we'll call the superclass
version of set font let's go ahead and
Wow see this is this is why I didn't
want to do it on Tiger so there is an
issue here unfortunately with code
completion
that's that came in very at the last
moment in Tiger it's a conflict between
app kit and Xcode we fixed the bug since
then but of course it didn't make it on
your seed so now you'll see oops didn't
mean to click on that that things aren't
quite ready that would have worked just
fine on pan Thor so I assure you that
that's a well-known bug let's just go
ahead and I'm gonna let's see talk about
one more thing in Xcode showing that
demo is not that amazing I mean it does
actually set the preferences and change
this style so the last thing I want to
tell you about is index templates in
Xcode so in order to speed up indexing
even more so we've made indexing ten
times faster for indexing your system
class files well you can actually get
rid of the time to index that all
together and that's done using a feature
called index templates and they're not
set up for you by default on the machine
but they are documented in there it's
very easy to do it's just running one
command-line application that will set
them up for you and the instructions for
doing that or down inside developer
extras Xcode templates
oh it's tiger that's right are you gonna
say use spotlight
ah anyhow so they're inside Xcode index
templates here yeah we're not sure
enough spotlight right and these
instructions tell you how to set it up
it's very easy it takes a couple of
minutes for it to index everything it
sets up index templates not just for
Java but also for the for cocoa project
types and carbon project types so what
that does is that when you create a new
project it'll instantly index all of the
system files you don't have to do it
every time you create a new project and
when you rebuild your index if you were
to do that which you shouldn't need to
do nearly as much as you did in the past
then that's is sped up quite a bit too
ok with that I think we'll bring it back
to Ted here ok all right so amp ants
very important to the job in an
environment and and it's a great build
system for Java up to this point we've
been focusing mainly on the jam build
system with the addition of ant into the
Xcode 1.5 and teeth out
we're not abandoning that the jam stuff
at all so you don't have to scramble and
move your stuff over we're just we're
providing options so in addition with
this and you get a bunch of templates an
empty project for built one for billion
jar and one for billion an application
jar so one with manifest and all that
the ant that comes is one six one the
latest release and you target using an
external build target one thing to note
we actually discovered another issue
quite well we're quickly trying to get
this out and that the one six one that
we have and we're distributing is
actually missing a few of the the the
classes so while it works for most
things if you discover that something is
missing just go redownload the ant
from ants website there's actually
instructions it's just a direct
replacement we don't do anything special
except name the folder ant versus ant
1.6 and all that just replace the one on
the drives and you're up and running so
the application developers server
preview this includes JBoss 3 to 3 it's
actually the final candidate version of
it or at the release candidate version
actually it includes Tomcat extact late'
and also an older version of ant the
older version of ant is actually
installed in a different location this
version will be going away and we're
gonna be using the new one in the 1.6
from the Xcode install currently the
templates point to the old one because
this actually came out before our Xcode
update but just continue using it and at
some point you may just need to switch
your build file if you're using one of
those templates but it's pretty easy a
deal this is also available in the
developer tools section of connect apple
comm one of the things that we like to
do is do demonstration of how easy it is
to do servlets and JT EE applications
we're actually doing a demo this in
building your website on Apple Computer
later
I think it's Thursday afternoon so the
application server in Xcode the the web
module is one of the templates that's
installed that's essentially servlet EJB
module for doing a Java Bean and of
course the enterprise application all
those templates are included in that
update one of the cool things about this
is that when you install this server
update it installs in a location that's
the same location as if you
deploying on Xserve with 10 server so if
you build in and set up everything on
this on the client machine using this
you can then deploy to Xserve without
having to worry about any directory
configuration stuff or anything like
that it's actually very easy of course
you can deploy to any platform you know
portable ant targets and all that so
it's actually something really cool to
check out
additionally we came out with the one
for to update for xcode this includes
Jay and I headed
stuff like that so if you had like the
the 1.2 of install Xcode and you update
to 1 for 2 and I'll send you of j'ni
libraries when you're building breaks
just download this one for to update and
you'll get all the headers and all that
they'll be installed in the right
location of course on Tiger it comes
with 1 4 to the Xcode 2.0 of course has
all these updates this also includes
source files and stuff our sources that
we can legally release and documentation
so definitely get get a hold of that so
building an Xcode I'm not gonna go into
so much the the philosophy and the the
UI of Xcode but we are going to touch on
at least some of this stuff for for the
Java and focus on the Java portions of
course on the left hand side you have
your source files and stuff like that
your products and your frameworks you
know or jars you also have underneath
that your targets and then of course
your executables the Java targets you
have the Jam targets and stuff like that
the external targets you would normally
use for calling ant or something like
that or a make file and of course you
have native targets for j'ni libraries
executables this is where you select
your your run debug configuration so if
say you want to debug your j'ni library
you can switch to gdb or if you want to
debug the job of stuff you can use the
Java debugger y'all do that on the xcode
are in the executable
your arguments that you're passing to
your jar file or your application you
set this all up from the executable and
then any environment variables that you
want to set so if you want to pass in I
guess Java home or something like that
that's something that you really don't
need on our platform but I mean you can
set that all up in the executable so I
keep talking about extending xcode to
ant is an external target and that's one
of the ways that xcode allows for
extending for Java stuff
an additional way is in the build phases
so if you have a gem target one of the
things Jam does is it calls out to
external tools and stuff like that so
you can use either a shell script build
phase and often use this for like
signing files or something like that or
a copy build phase I'm actually going to
go into those right here so shell script
build phase this is the kind of thing
when you're doing J&I target use a Java
H you call job H from the shell script
build phase signing jar files the shell
script build phase if you have an
executable or a directory set up that
you want to set up for your built end
result the shell script build phase is
useful for that that's what we actually
use it for to cephalization files for
packages also if you have like a bunch
of say properties files you want to
write or something like that and you
want it to be dynamic you can use that
in the shell script build phase the
copies files build phase this is where
you want to like move things into your
your build results this is something
where if like you have a J&I library you
want to copy it into your application
bundle if you want to if you have say
one of the things that you can do is you
can call out using runtime DXE to
external tools so if you want to copy
those into your application bundle
copies files build phase nice thing
about that you can hide everything
within your application bundle and not
have to worry about somebody you know
throwing away things because they
realize what it is and then I'll send
your application breaks so I'm gonna
give you a quick tour of Xcode let me go
to the the Panther machine over here so
what I'm doing right here is for the
most of the talk we're actually going to
focus on ant but like I said we're not
really abandoning the jam stuff at all
we're just providing the option so what
I'm going to do is show you a little bit
about some of the jam stuff that is in
there currently in the 1.2 and in the
1.5 and 2.0 of course this is the
targets and stuff that I talked about
these are the all the files there's
different ways that you can actually
view them just double click on them I
know this is all pretty rudimentary but
for some people haven't really used it
this is actually important for them and
if you want to include a file on a
target here's the check box for it so if
you have it over here you can see of
course that the build results aren't
included in the target
double-click on the target they'll
actually bring up the property list this
hasn't actually changed that much from a
project builder so if you use it in
there it's pretty much the same it's
still in the the 1.2 the the panels that
are important to you or the java the
compiler settings this is where you can
select java c jikes and stuff like that
set your target JVM if you want to
target something else
the Java archive settings this is where
you include a manifest file so if for
some reason well of course we all want
our double-click little jars to be
launched Abul so what you do is you put
the manifest file to root of the project
and then just type in the name here and
of course all these are properties so if
you set something in there it'll show up
in this list and you can go on and
configure things manually so if you
wanted to call it to another Java
compiler or something like that Greg is
actually going to show you that pure
Java is specific down here these are the
actually the P list entries and these
are
things that are used when you're
launching your double clickable
application these are the kind of things
like your properties if you want to add
additional properties for the the
Macintosh platform I additional JVM
options say if you want to do profiling
or something like that you can type that
in here set your your heap size set the
current working directory to the
contents Java the resources Java
subdirectory this is say if the current
working directory of the java
application is normally just outside the
execute of executable bundle but you can
actually set to internal to the
executable bundle so that when you're
calling out to external tools or
something like that or referring to
property files there within the actual
application bundle and sometimes this is
just something if for some reason you
say if you see an error can't launch the
invoke the NS JVM or something like that
it means this was accidentally checked
just uncheck it so and then over here
that's enough the targets pretty much
for the jam stuff this is the executable
and this is where you would you could
create a custom one but you can go in
you set your launch arguments things are
passed to your application environment
variables like I said this looks a
little bit different in the 1.2 they
actually have a couple of tabs across
the top let me see if I got actually on
this one I think it's the same look and
feel and I can actually show it to you
if we switch the machine can you do that
for me real quick yeah over to this
other machine let me just show you that
real quick sweet I'm on the right 1/2
so let's go into here so looks a little
bit different but arguments and then
debugging this is where you actually set
let's see I have an indexes project so
it doesn't have all that yet but that's
essentially where you set up all the
jams stuff and that's kind of stuff that
we currently provide we actually if you
look at the the project builder
documentation it will point you to clear
all that up for you but we're actually
coming out with new Xcode for Java
documentation soon our tech pubs people
are actively working on it so let's go
back to the slides where are you there
so I keep hitting this again but ant
integration it's an external target it's
the same as like a legacy make file
target it's we're essentially calling
out to an external build tool some of
the arguments that you can pass to it
the standard ones in our templates is
what I have listed here but you can
actually pass in any other kind of
options you want it's you know you're
calling out to an external tool so and
then in the build styles
if you've used xcode build styles for
something else
you can set environment variables and
stuff like that they'll be passed on to
the targets and then they have say you
have say some sort of property that you
want to pass in you can just add a
dollar sign and then whatever the value
is that you defined in the build style
onto that executable line and that'll
automatically be passed to it when you
define that whenever you've done it you
calling out to external target there's a
lot of environment variables that we
pass along if you look at the build
settings notes under the help the help
menu this will tell you a lot more about
available options that you can kind of
capitalize on so definitely check that
out this is something that's kind of
overlooked but a valuable piece of
information
so j2 I mean this is a we're not really
promoting j2me on our platform but it's
a great example of what you can use ant
to build using build for on our platform
I'm actually we're going in the DMZ
we're going to provide a sample template
for building Jade j2me midlet that will
be in the disk image available tonight
after for this session it's a custom
executable like I said or it's a custom
executable to run the mid Pete emulator
you can use Bluetooth push it the file
over from your be either your laptop
your desktop machine actually let's go
back to the slides actually real quick
thank you it's a Bluetooth executable
all right sorry about that
use bluetooth to push it over when
you're pushing over a jar file for mid P
you can't define any properties in the
jad file but if you if there's any
properties that you need you can just
define them in your actual executable
and push it over and mid pecan actually
is a jad file to define external
additional properties that we'd be
passed in when you're pushing over with
bluetooth you can only send one file at
a time so just define those within New
York's acute Abul and oh yes I most
importantly the emulator I'm using is
actually from Mike powers website it's
empowers dotnet and it's the mid P - OS
OS X directory of course this URL is
provided in the disk image so don't
worry about writing it down and actually
we just found out today that he's going
to make available a j2me 2.0 emulator so
as soon as that's available we'll make
that available or at least point you to
it he he'll probably will get it to you
somehow
I just heard about today so that's why
I'm just kind of stumbling with that so
let's actually go over to the Panther
and let's do a quick j2me demo and so
let's go over to the Panther machine and
all right and let me go over I've
already installed the template for the
j2me and so if you follow the directions
included in a disk image just we'll show
you how to get that in there and once
you do that it'll actually show up in
Xcode as a project template so let me
just go ahead and let me build it on the
desktop let me just call it asteroids
that's the ast er I'm a creative speller
so I have to double checked all this and
at this point it just pretty much just a
hello world application let me launch
x11 the current emulator the mid p10
emulator is an X 11 executable so let's
go ahead just run this real quick and
show you comes up there it is it's your
phone on an emulator go ahead just
launch
HelloWorld not very exciting but proof
of concept so but next step is let's
actually go in and let's see this should
be in my home directory and let's get
this source what you see over here let
me just go to intuit is that you got
this blue source directory so I'm gonna
go in delete that file it should go
ahead and delete in there and that's
copying these sources from over here and
this is a it's a GPL version of
asteroids game I just look on google for
asteroids mid P and you should be able
to find it and let's see the next step
actually is the the manifest let me
update those actually let's just go in
and copy it in from the other directory
the manifest on the jad file let's just
copy that in a place place now in theory
I should just go ahead and be able to
build using the current template let's
see build show build successful that's
always a good sign I went through did
did the whole build here and we should
just be able to run it let's see if it
actually runs oh no that's the whole
world let's try this again oh this demo
is not going well but the concept is and
what we're doing is we're actually
showing ant building for mid P and if
you saw it earlier in the Java State of
the Union it does build in everything
like that
the asteroids for Mac OS 10 but that's
only a part of the story let's just send
this file over actually to my Bluetooth
phone so let me go into my home
directory and I got the asteroids the
bin and our the build bin and let me
just send this jar file over and go
ahead turn on the camera give it a
second it tends to fall asleep there it
goes and with any luck there's the
camera phone
notice the aspect ratio is not
completely maintained but that it's a
piece of sample code that's actually a
cookie component right there and let's
go ahead and send that file over that
should wake up the phone
unable to validate device
all right these demos are all going
pretty good today um but it does so
basically what would happen is I'd send
over the file the phone automatically
wakes up which is actually pretty cool
to see and it says do you want to accept
this file
it doesn't just blindly accept any file
I say yes it downloads it starts the
file and you got mid peep running on
your your phone that you built on Mac OS
10 and it's actually pretty easy the
sample template will be in the disk
image and it'll be great for you to try
it out so let's go back to the slides
and continue on so that was the j2me
demo so one of the problems that people
have run into is building J&I on Mac OS
10 isn't exactly straightforward let's
talk a little bit about it it's actually
easy once you know how when you're
building a mid P target you want the
library to be Nate Ani target you want
the library the executable the result to
have the start with at lib and then end
with the extension J and I live and so
if say you want a deer to be able to do
a system dot load library foo you would
actually name your target Lib foo and
then change the executable of the
extension to PJ and I Lib and so the
exit the j NR library would be Lib Fuji
and I live so there's two steps to do
this in Xcode the first step normally
what I do is I split this into multiple
targets the first step is actually to
build the headers and that's where you
call Java H with a shell script and then
to build a J and I library and that's
the second target and then of course you
have your actual application target that
I'm just focusing on the TI library at
this point so the header target you add
you create a new target
a package target a jar Java package
that's essentially to jar file add all
your classes to it with the native
methods and any supporting classes that
you need to compile those typically you
don't add all your classes because if
you have 100 or so classes and you'll
end up building all those classes many
times you just want to include a subset
and then add a shell script build phase
to this target this is essentially what
you would want to add as a shell script
build phase we actually have J nice
samples that includes this stuff so you
don't have to write it down you can get
it from our sample code website but
essentially add the the the jar file to
the class path and then job H will if
you pass into all the class names with
the native methods it'll generate all
the header files for you the next start
step is the j'ni library target this is
a BSD dynamic library of course named
Lib and then whatever the extension the
library that you actually want to have
loaded with system that load library you
change the extension to J&I lib this is
actually a build option you set the the
native build option for wrapper under
sort extension to j'ni lib you do this
with the custom options the build
options and this will actually give you
a J&I lib extension versus a dilated
extension and of course you can build C
C++ objective-c anything you want into
that j'ni library just expose you know C
entry points because that's what J&I
expects so Jan once you get your j'ni
library built the next step is actually
deploying it or or copying into your
application or something like that of
course like I said before the copy files
build phase that is the one where you
copy the J&I library into your java
application bundle and actually if i use
in the copy files build phase there's a
pop-up that you can select where in the
application bundle and you would want to
use the job of resources we add that to
the dialogue search path for J and I
the Java Web Start you would actually
want to copy that file or you would want
to add that file to to the Web Start
project and so that will include the jar
and are the JI library in your jar and
so when you download the Java Web Start
it'll actually application it'll be able
to find that jar for you and of course
talking about J&I libraries there's a
few more places that you can actually
install them on the system besides the
application bundle of course anywhere in
the job search path we look for them
additionally we look in the the library
Java extensions at the root of the
system so if you want to install a Jane
in our library for the entire system
that's the place to put it or if you
want to install a J&I library just for
the specific user that's currently
running you can install it in the same
directory structure but in their home
directory and we'll look there for it
also so just a quick note while we're
talking about java J&I there's a few
things to be aware of some of the
threading between Java and our GUI is a
cocoa GUI and what happens is when
you're running a cocoa application it
actually the the app kit thread is
thread 0 and that is the one that is
actually receiving all the cocoa events
and stuff like that you don't want to
block that and then of course you don't
want to block the java.awt thread so
when calling between say cocoa and Java
there's a couple things that you want
may want to use is in the when you call
an objective-c from the Java side of it
you may want to use perform selector on
main thread and what that'll do is allow
you to dispatch an event to the
objective-c app kit thread and then be
able to let your aw t thread return say
if it was in responsive Benton click or
Mouse down or something like that if you
wait until done you'll actually end up
blocking that thread so that may be
something you may not want to do and
then when you're calling back in the
Java from cocoa you want to avoid
running Java on the App kit
so to do that you'd actually use swings
and Vulcan weight and book later or
something like that or actually invoke
and weight and Vulcan weight is kind of
like the wait until done in that you
might end up paying the app kit thread
so be very cautious if you use that I
should probably have had this build on
to put a couple X's on those but um
specifically if say you're using JWT
oracle key component JWT paints on the
AWT dispatch thread so if you're calling
out to a native coco function or
something like that don't block that AWT
thread because your application will sit
there and won't be responsive and tell
like it comes back from the cocoa app
kit and then in cocoa component it
paints on the the main cocoa thread if
you block that then all of a sudden you
won't be getting any event sent to your
a w t from cocoa so don't block that
thread so let me bring up Greg Boyle
singer we're gonna talk about debugging
in Xcode and yeah I'm going to show you
a little bit a bit about debugging in
Xcode and another little thing about 1/5
I think it's pretty funny the way that
we have Java 1/5 which son calls tiger
and our OS is called Tiger usually from
us you'll never hear us call Java 1/5
tiger because it's confusing for us too
so first off I'm going to show you how
to debug a Java applet in Safari
I had told I believe it was Ted that I
could do this and he said I didn't even
know that so we thought it would be a
good demo to have here so I'm using
Tiger here I'm going to create a swing
I'm sorry the tiger demo machine demo
one thank you
so I'm just gonna create this little
example on the desktop what we have here
is just a standard really simple swing
application swing an applet I'm sorry
and what you can do is create a custom
executable like Ted had mentioned
earlier you go to the project menu you
create a custom executable we're gonna
call it Safari choose it from the
chooser and when you edit the custom
executable here you'll see that the
executable path is application Safari
and to debug it you'd pick the Java
debugger here this will launch Safari
using Xcode and hit our breakpoint this
morning and I didn't want to tempt the
demo gods I was thinking that other
applications that do run Java using
WebKit could also be debug the same way
but I didn't want to try any of those
other WebKit applications right now so
start it up Safari using Xcode I've set
a breakpoint in the paint method here
and I'm going to open the HTML file for
my applet it's going to load the applet
and now it hit the breakpoint you can
see with standard Java debugging you get
to see your thread stack here arguments
you couldn't examine these items here
you can step through code wires step
over
sorry that was bye-bye code and then you
could just let it continue and then
there's your whoops there's your Java
applet in Safari oh oh oh I got a
repaint
that's why doesn't that make sense and
so so you can debug Java applets in
Safari if you deploy your apples that
way another handy tool that some people
may not be totally aware of is the Java
plug-in for debugging it's really useful
when I'm debugging the actual Java
plug-in I use the Java plug-in control
panel a lot as well as Java debugging
and you can even debug the native AWT
code in Safari but you could pass all
sorts of interesting things to the to
the runtime when it's invoked using the
Java Runtime parameters here you can set
the boot class path that's what I do
because I'm always replacing a WT or the
plug-in so you would apply it and then
the next time you run Safari and you
open that applet that I just ran you'll
see that what we ran it from you
couldn't see the console if I just run
it from the command line of course so
here you could see that the output you
get to see where all your classes are
loaded from so I find it particularly
useful when I'm debugging if I have got
my boot class path setup wrong I use the
verbose but verbose class loader option
for the Java plug-in there so what I'm
going to go to now is the slides
so like I showed you just now that you
have the you select the Java debugger in
your custom executable and you'd select
Safari there and if you need to you can
just bug both Java and J&I code
simultaneously outside of Safari because
Jay and I cannot run in of applet
without certain security issues
typically you'd use the Java debugger in
Xcode and then you could attach to that
process from the command line with gdb
and see your stack there alternately you
could probably do it the other way
around if you launched your applications
such that it could be debugged with jdb
I did the demo before the slides so now
I'm gonna talk about how you can use the
java 1 5 preview in xcode xcode is an
amazing tool because it has so many
options they they're they it's amazing
what it can do
because without even knowing about java
1/5 it can both build it and run it and
that's very useful so some things to
know about java 1/5 it's a preview it's
not all complete yet so in tiger it's
only in tiger and in Tiger 142 is still
the default Java you can only run it
from the command line we didn't set it
up so that double clickable dot apps
work even double click little jars don't
do anything for 1/5 so what you have to
do is use the full version path in the
terminal our Java is set up so that we
could have multiple Java's installed at
once it's system library frameworks Java
VM frameworks versions 1.5 commands and
then Java and all the other regular
tools are there - such as Java H Java C
and jar other all those other types of
tools are there and the new ones pack
200 and I'm not sure of the other ones
right off the top of my head right now
you can only debug Java with the jdb
command-line tool for 1/5 in tiger we
don't have the debugger set up inside of
xcode yet it's a problem in the jdk not
in xcode and AWT inswing are present in
one-five bill but if you try to run any
you'll find you'll quickly crash in some
kind of font code so unfortunately
that's not yet ready for the preview but
we'll have it soon so now I'm gonna show
you how to do how to use one five in
Xcode go back to Xcode over here close
up that project I had going any more I
mean we're going to use the new ant
templates available in Xcode
there's no ant templates for applets yet
so that's why I wasn't able to I wasn't
able to show the swing applet in ant so
we're gonna call this one Java one five
so these are in the release notes for
one five but the way to get one five to
compile using ant first off we have to
get it to compile using it and we use
here we use four equals true so this is
going to fork the Java C off into a new
process and this is where you're going
to give the path to the executable ant
would seem to be versatile enough that
you can also use any version of Java
that you may have laying around
oops
well so much for yeah I don't know so I
have to type in the full path what I've
done and what if you do one five
development in the preview what you'll
want to do is certainly make a
command-line shortcut an alias and your
terminal to this command because it's
quite long to type in all the time
especially without code without the
command line completion so you would
type in the full path to the executable
and the build.xml now thank you thank
you again so right now this source here
is a very simple hello world program and
so I made a very complicated one I
don't know why this works
Oh actually it's already in my clipboard
isn't it I made a very complicated one
five only hello world we're using the
generic string ArrayList to add hello
world here and we're using the for loop
here I don't know what they enhanced
for-loop is what I believe they call it
and this is just to show you that I'm
going to be able to build using one five
and Xcode because this will not build
this sample here will not build in one
four because of the generics and the odd
for loop choose build we are not having
luck with the demos today
thank you again so now we'll see that
the build has succeeded beyond all our
beliefs what we'll make now is a new
custom executable so this is how we will
be able to run one 5in in Xcode so it
because it has all these custom
executables and you could set the
variable names you can even run build
one five with jam if you'd like to so
once again I have to type in that path
because I can't figure out how to get
see the clipboard does work in Tiger so
now we're gonna run it using one five in
Xcode and it's a terribly exciting one
that says thank you
what was that class called
I'm terribly sorry about that I should
have remembered that now you'll see that
we have yet another problem
I did this this morning well we always
have my favorite thing
so we built this job this class file
here using Xcode and now I ran that 1/5
program using 1/5 so you can see that X
codes very versatile it can do all these
things I don't know why I wasn't able to
get it to run using Xcode today because
I did it this morning so I think that
now we're going to bring Ted back on up
to on stage thank you great so in theory
what we showed you is how Xcode can help
you with your Java development on Mac
os10 we've gone into things that we've
talked about the ant that's coming with
the 1.5 in the 2.0 we've talked about
some of the things like not quite cross
compiling but targeting other platforms
say j2me ant is very useful for that we
talked about the application server
update and the one for to update for the
current Panther install with this I
think we've gotten that you guys enough
information get you started probably
enough to get you up and running and
asking questions be sure to use some of
these things one thing that we don't
have up there that's actually a very
useful resource is the Java developers
mailing list if you go to list a pecan
join the Java - dev mailing list this is
an extremely active mailing list you're
going to want to set up a filter to put
it into a folder for you otherwise it's
going to fill up your inbox rather
quickly but it nice thing about it is
you can ask pretty much any question on
there and there's usually somebody up
around the world who will be able to
answer it without too much too long and
occasionally the job engineer is
actually when they have time we'll work
on the list and you'll get the
information directly from the source so
with that we move on to the Q&A
thing to it yeah definitely the mid P
stuff there's an article on Sons website
about doing mid P development on Mac
os10 check that out it goes into a lot
of details from the command line and now
Q&A