Skip to Content
Swing Hacks
book

Swing Hacks

by Joshua Marinacci, Chris Adamson
June 2005
Intermediate to advanced
544 pages
22h 24m
English
O'Reilly Media, Inc.
Content preview from Swing Hacks
422
|
Chapter 11, Native Integration and Packaging
#83 Control iTunes Under Windows
HACK
Working with COM
The Component Object Model (COM) is a standard way for Windows com-
ponents to expose functionality that other programs can call at runtime.
com4j (https://com4j.dev.java.net/) is an open source library that creates
connections from Java programs to COM objects. com4j has two parts: a
command-line program to create the Java interfaces that your program will
call, and a native library that binds your program to the COM object at run-
time.
com4j uses class annotations to do its magic, so you can only
use it with Java 5.0 or greater.
To get started, download the com4j package at https://com4j.dev.java.net/
servlets/ProjectDocumentList. With the com4j stubber and the iTunes exe-
cutable in your current directory, you can generate the interfaces like this:
java -jar tlbimp.jar -o jtunes -p test.jtunes iTunes.exe
This command will load the iTunes executable and look for COM defini-
tions. Once they are located,
tlbimp will generate a bunch of Java interfaces
in the
test.jtunes package and put the .java files into the jtunes directory. If
you look at the generated Java interfaces, you will see a whole slew of meth-
ods and objects for playing, querying tracks, and dealing with virtually every
other feature of iTunes. com4j will also pull out any embedded documenta-
tion and insert the documentation as JavaDoc ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning Swing GUI Programming

Learning Swing GUI Programming

Brian Cole
Java Swing

Java Swing

Robert Eckstein, Marc Loy, Dave Wood
JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour

Publisher Resources

ISBN: 0596009070Purchase bookErrata Page