10fa6ae01e
Reviewed-by: erikj, prr, ihse
221 lines
9.4 KiB
Plaintext
221 lines
9.4 KiB
Plaintext
Working on AWT and Java2D code with NetBeans
|
|
|
|
This project includes most of Java2D and AWT-related files,
|
|
allows easy navigation and builds from within NetBeans.
|
|
|
|
Since both AWT and Java2D have lots of native code, this
|
|
project uses "make" targets for building.
|
|
|
|
Unfortunately currently this project doesn't support
|
|
working with native code. Meaning, there is no navigation, code
|
|
completion, refactoring, etc.
|
|
In the future we will provide native code support.
|
|
|
|
You can certainly install the C/C++ pack for NetBeans 6.0
|
|
once it becomes available, or use any other editor for
|
|
working with C/C++ files.
|
|
|
|
In order to use this project from within NetBeans you will have
|
|
to perform a full jdk build first.
|
|
|
|
Here are the steps:
|
|
1. setup your jdk build environment as described in
|
|
other documents (see build documentation)
|
|
|
|
2. perform a full jdk build (preferably a FASTDEBUG build,
|
|
as it simplifies the debugging - the classes and object files
|
|
will be built with the debug information).
|
|
You only need to build jdk's "all" target:
|
|
#> cd jdk/make
|
|
#> make all > build.log 2>&1
|
|
|
|
3. set "make" and "make.options" properties in your
|
|
~/.openjdk/build.properties file (see the main README
|
|
file for more information on property files)
|
|
to set up the environment in NetBeans.
|
|
|
|
To get a list of variables you most likely will need to override
|
|
to make the the build work in NetBeans, you can do something like this
|
|
(on Windows):
|
|
#>env | grep ALT
|
|
ALT_JDK_IMPORT_PATH=c:/devtools/java/jdk1.7.0
|
|
ALT_BOOTDIR=c:/DevTools/java/jdk1.6.0
|
|
|
|
If your build is a FASTDEBUG build, don't forget
|
|
to set FASTDEBUG=true in the property file as well so that what you
|
|
have built from the terminal matches what will be built from NetBeans.
|
|
|
|
Set "make.options" in your build.properties
|
|
accordingly:
|
|
make.options=\
|
|
ALT_JDK_IMPORT_PATH=c:/devtools/java/jdk1.7.0 \
|
|
ALT_BOOTDIR=c:/DevTools/java/jdk1.6.0 \
|
|
FASTDEBUG=true
|
|
make=c:/devtools/cygwin/bin/make
|
|
|
|
4. Windows only: make sure you either call vcvars32.bat
|
|
file which sets the compiler environment
|
|
(typically located in <YourVisualStudioInstallDir>/VC7/bin)
|
|
and start NetBeans from the same terminal,
|
|
or make Visual Studio register its environment
|
|
variables globally.
|
|
(When building on 64-bit Windows platform, use setenv.cmd
|
|
from Platform SDK instead of vcvars32, as described in the
|
|
build documentation)
|
|
|
|
5. Now you can launch NetBeans
|
|
|
|
Notes on building the project from NetBeans
|
|
|
|
If you work only with Java files, you can compile them
|
|
with "Compile Single File" target ("F9" by default), the ant build
|
|
will compile the class files into the correct directory automatically.
|
|
|
|
However, if you touched any of C/C++ files,
|
|
you will need to use "build main project" ("F11") which launches
|
|
"make" on a set of directories.
|
|
|
|
Same goes if you touched a Java file which has native
|
|
methods. You will need to run the build so that
|
|
"javah" can generate the JNI header files used by
|
|
the native code.
|
|
|
|
Demos
|
|
|
|
The default run target for this project is Font2DTest,
|
|
which is launched with the runtime you built.
|
|
|
|
You can also start other demos by selecting a demo
|
|
in the Project or Files view and choosing "Run" from
|
|
the menu.
|
|
|
|
In particular, there is a J2DBench demo project,
|
|
which is a Java2D benchmark. To run it,
|
|
select java2d.J2DBench/build.xml node in the
|
|
"Projects" explorer and execute "Run" target.
|
|
For more information on this benchmark, see
|
|
the project's README file in the "Files" view.
|
|
|
|
Notes on using CND (C/C++ pack) with this project and NetBeans.
|
|
|
|
As mentioned above currently a project for working with native code is not
|
|
provided. However, you can set it up by yourself if you have
|
|
access to CND pack for NetBeans 6.0.
|
|
|
|
First, install CND as described here (this is a page for CND 5.5,
|
|
there likely will be one for 6.0 as well):
|
|
http://www.netbeans.org/community/releases/55/cnd-install.html
|
|
and make sure everyting works it works.
|
|
|
|
Then, create a new C/C++ project of "from existing code" type (see page
|
|
mentioned above for examples). The project should be located in the same
|
|
directoryas this project is - on the same level. Call it something like
|
|
"awt2d-native-${platform}-${arch}". So, for example, you may have
|
|
jdk/make/netbeans/awt2d
|
|
jdk/make/netbeans/awt2d-native-windows-i586
|
|
|
|
Specify the top level Makefile (jdk/make/Makefile), even though
|
|
you will not be using, as the Java awt2d project is set up
|
|
for building the workspace (thus make sure it's the default project,
|
|
so when you hit "Build Project" it's awt2d one that's chosen).
|
|
|
|
The most important thing is to specify the directories which will
|
|
be included into this project, the defines, and the directories for
|
|
include files.
|
|
This will enable code completion and limited navigation.
|
|
|
|
Using the project wizard, select the source directories you're interested in.
|
|
|
|
For example,
|
|
src/share/native/sun/java2d
|
|
src/windows/native/sun/java2d
|
|
....
|
|
(this will recursively include the subdirectories)
|
|
|
|
Then set the list of the includes required by CND to enable code assistance.
|
|
You can get a complete list of include directories by looking at your
|
|
build log file and checking what directories are included with "-I" when
|
|
the files you're interesed in are built (you can probably devise some
|
|
script to generate the list of include files relative to the native
|
|
cnd project directory, and the list of defines passed to the compiler)
|
|
|
|
For example, on Windows x86, you might have something like this
|
|
(a somewhat complete list of awt and 2d native directories on windows):
|
|
|
|
../../src/share/javavm/export;
|
|
../../src/share/native/common;
|
|
../../src/share/native/sun/awt/debug;
|
|
../../src/share/native/sun/awt/image/cvutils;
|
|
../../src/share/native/sun/awt/image;
|
|
../../src/share/native/sun/awt/medialib;
|
|
../../src/share/native/sun/awt;
|
|
../../src/share/native/sun/font/bidi;
|
|
../../src/share/native/sun/font/layout;
|
|
../../src/share/native/sun/font;
|
|
../../src/share/native/sun/java2d/cmm/lcms;
|
|
../../src/share/native/sun/java2d/cmm;
|
|
../../src/share/native/sun/java2d/loops;
|
|
../../src/share/native/sun/java2d/opengl;
|
|
../../src/share/native/sun/java2d/pipe;
|
|
../../src/share/native/sun/java2d;
|
|
../../src/windows/javavm/export;
|
|
../../src/windows/native/common;
|
|
../../src/windows/native/sun/awt;
|
|
../../src/windows/native/sun/java2d/d3d;
|
|
../../src/windows/native/sun/java2d/opengl;
|
|
../../src/windows/native/sun/java2d/windows;
|
|
../../src/windows/native/sun/java2d;
|
|
../../src/windows/native/sun/windows;
|
|
../../build/windows-i586/tmp/sun/sun.awt/awt/CClassHeaders;
|
|
../../build/windows-i586/tmp/sun/sun.awt/awt/obj;
|
|
../../build/windows-i586/tmp/sun/sun.awt/awt/obj_gO;
|
|
../../build/windows-i586/tmp/sun/sun.awt/jpeg/CClassHeaders;
|
|
../../build/windows-i586/tmp/sun/sun.awt/splashscreen/CClassHeaders;
|
|
../../build/windows-i586/tmp/sun/sun.font/fontmanager/CClassHeaders;
|
|
../../build/windows-i586/tmp/sun/sun.font/t2k/CClassHeaders;
|
|
C:/devtools/VS2003/SDK/v1.1/include;
|
|
C:/devtools/VS2003/VC7/ATLMFC/INCLUDE;
|
|
C:/devtools/VS2003/VC7/INCLUDE;
|
|
C:/devtools/VS2003/VC7/PlatformSDK/include;
|
|
C:/devtools/VS2003/VC7/PlatformSDK/include/prerelease;
|
|
|
|
(you can format this into a single line with ';' delimiters and paste it
|
|
into the text field instead of entering them one by one)
|
|
|
|
Note that most paths are relative to the native project directory -
|
|
this helps if you decide to relocate the workspace later. The ones that
|
|
aren't relative are paths to external include directories, like those
|
|
of the Platform SDK.
|
|
On Unix platforms these may be directories like /usr/include.
|
|
|
|
The parser must know some defines to correctly parse the source files,
|
|
these can also be obtained from the log file. For example, on Windows
|
|
x86 with debugging enabled, the defines would be something like this:
|
|
D3D_OVERLOADS; UNICODE; _UNICODE; WIN32; IAL; _LITTLE_ENDIAN; WIN32; _X86_;
|
|
x86; WIN32_LEAN_AND_MEAN; INTERNAL_BUILD; JDK_MAJOR_VERSION='"1"';
|
|
JDK_MINOR_VERSION='"7"'; RELEASE=1.7.0-internal; DEBUG="true"
|
|
|
|
(again, format it into a single line with '; ' delimiter - note the
|
|
space after ';' - and paste into the corresponding text field)
|
|
|
|
Note that the list of include directories will be different on different
|
|
platforms and architectures - consult you build log file.
|
|
|
|
After the project is created a loaded, you may want to check the list
|
|
of include files which weren't found (right-click on the native
|
|
project root in Projects exprorer, and select "View failed #include Directives"
|
|
from the popup menu. Update the inlcude directories list accordingly.
|
|
|
|
You can later create a different configuration for non-debug build,
|
|
just make a copy of your current configuration - call it ${arch}-debug
|
|
(in the native project's Properties dialog) and remove "DEBUG=true" from
|
|
the list of defines.
|
|
|
|
Note that with both Java and native projects opened the default
|
|
heap size NetBeans starts with might not be sufficient for comfortable work,
|
|
so you may need to increase it. You can do it either from the command line
|
|
or by editing your ~/.netbeans/dev/etc/netbeans.conf file and adding
|
|
something like this:
|
|
-J-Xms312m -J-Xmx512m -J-XX:PermSize=128m -J-XX:MaxPermSize=200m
|
|
to netbeans_default_options property.
|