J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | Working on AWT and Java2D code with NetBeans |
| 2 | |
| 3 | This project includes most of Java2D and AWT-related files, |
| 4 | allows easy navigation and builds from within NetBeans. |
| 5 | |
| 6 | Since both AWT and Java2D have lots of native code, this |
| 7 | project uses "make" targets for building. |
| 8 | |
| 9 | Unfortunately currently this project doesn't support |
| 10 | working with native code. Meaning, there is no navigation, code |
| 11 | completion, refactoring, etc. |
| 12 | In the future we will provide native code support. |
| 13 | |
| 14 | You can certainly install the C/C++ pack for NetBeans 6.0 |
| 15 | once it becomes available, or use any other editor for |
| 16 | working with C/C++ files. |
| 17 | |
| 18 | In order to use this project from within NetBeans you will have |
| 19 | to perform a full jdk build first. |
| 20 | |
| 21 | Here are the steps: |
| 22 | 1. setup your jdk build environment as described in |
| 23 | other documents (see build documentation) |
| 24 | |
| 25 | 2. perform a full jdk build (preferably a FASTDEBUG build, |
| 26 | as it simplifies the debugging - the classes and object files |
| 27 | will be built with the debug information). |
| 28 | You only need to build jdk's "all" target: |
| 29 | #> cd jdk/make |
| 30 | #> make all > build.log 2>&1 |
| 31 | |
| 32 | 3. set "make" and "make.options" properties in your |
| 33 | ~/.openjdk/build.properties file (see the main README |
| 34 | file for more information on property files) |
| 35 | to set up the environment in NetBeans. |
| 36 | |
| 37 | To get a list of variables you most likely will need to override |
| 38 | to make the the build work in NetBeans, you can do something like this |
| 39 | (on Windows): |
| 40 | #>env | grep ALT |
| 41 | ALT_JDK_IMPORT_PATH=c:/devtools/java/jdk1.7.0 |
| 42 | ALT_DXSDK_PATH=c:/devtools/DirectX/DXSDK_Dec06 |
| 43 | ALT_BOOTDIR=c:/DevTools/java/jdk1.6.0 |
| 44 | |
| 45 | If your build is a FASTDEBUG build, don't forget |
| 46 | to set FASTDEBUG=true in the property file as well so that what you |
| 47 | have built from the terminal matches what will be built from NetBeans. |
| 48 | |
| 49 | Set "make.options" in your build.properties |
| 50 | accordingly: |
| 51 | make.options=\ |
| 52 | ALT_JDK_IMPORT_PATH=c:/devtools/java/jdk1.7.0 \ |
| 53 | ALT_DXSDK_PATH=c:/devtools/DirectX/DXSDK_Dec06 \ |
| 54 | ALT_BOOTDIR=c:/DevTools/java/jdk1.6.0 \ |
| 55 | FASTDEBUG=true |
| 56 | make=c:/devtools/cygwin/bin/make |
| 57 | |
| 58 | 4. Windows only: make sure you either call vcvars32.bat |
| 59 | file which sets the compiler environment |
| 60 | (typically located in <YourVisualStudioInstallDir>/VC7/bin) |
| 61 | and start NetBeans from the same terminal, |
| 62 | or make Visual Studio register its environment |
| 63 | variables globally. |
| 64 | (When building on 64-bit Windows platform, use setenv.cmd |
| 65 | from Platform SDK instead of vcvars32, as described in the |
| 66 | build documentation) |
| 67 | |
| 68 | 5. Now you can launch NetBeans |
| 69 | |
| 70 | Notes on building the project from NetBeans |
| 71 | |
| 72 | If you work only with Java files, you can compile them |
| 73 | with "Compile Single File" target ("F9" by default), the ant build |
| 74 | will compile the class files into the correct directory automatically. |
| 75 | |
| 76 | However, if you touched any of C/C++ files, |
| 77 | you will need to use "build main project" ("F11") which launches |
| 78 | "make" on a set of directories. |
| 79 | |
| 80 | Same goes if you touched a Java file which has native |
| 81 | methods. You will need to run the build so that |
| 82 | "javah" can generate the JNI header files used by |
| 83 | the native code. |
| 84 | |
| 85 | Demos |
| 86 | |
| 87 | The default run target for this project is Font2DTest, |
| 88 | which is launched with the runtime you built. |
| 89 | |
| 90 | You can also start other demos by selecting a demo |
| 91 | in the Project or Files view and choosing "Run" from |
| 92 | the menu. |
| 93 | |
| 94 | In particular, there is a J2DBench demo project, |
| 95 | which is a Java2D benchmark. To run it, |
| 96 | select java2d.J2DBench/build.xml node in the |
| 97 | "Projects" explorer and execute "Run" target. |
| 98 | For more information on this benchmark, see |
| 99 | the project's README file in the "Files" view. |
| 100 | |
| 101 | Notes on using CND (C/C++ pack) with this project and NetBeans. |
| 102 | |
| 103 | As mentioned above currently a project for working with native code is not |
| 104 | provided. However, you can set it up by yourself if you have |
| 105 | access to CND pack for NetBeans 6.0. |
| 106 | |
| 107 | First, install CND as described here (this is a page for CND 5.5, |
| 108 | there likely will be one for 6.0 as well): |
| 109 | http://www.netbeans.org/community/releases/55/cnd-install.html |
| 110 | and make sure everyting works it works. |
| 111 | |
| 112 | Then, create a new C/C++ project of "from existing code" type (see page |
| 113 | mentioned above for examples). The project should be located in the same |
| 114 | directoryas this project is - on the same level. Call it something like |
| 115 | "awt2d-native-${platform}-${arch}". So, for example, you may have |
| 116 | jdk/make/netbeans/awt2d |
| 117 | jdk/make/netbeans/awt2d-native-windows-i586 |
| 118 | |
| 119 | Specify the top level Makefile (jdk/make/Makefile), even though |
| 120 | you will not be using, as the Java awt2d project is set up |
| 121 | for building the workspace (thus make sure it's the default project, |
| 122 | so when you hit "Build Project" it's awt2d one that's chosen). |
| 123 | |
| 124 | The most important thing is to specify the directories which will |
| 125 | be included into this project, the defines, and the directories for |
| 126 | include files. |
| 127 | This will enable code completion and limited navigation. |
| 128 | |
| 129 | Using the project wizard, select the source directories you're interested in. |
| 130 | |
| 131 | For example, |
| 132 | src/share/native/sun/java2d |
| 133 | src/windows/native/sun/java2d |
| 134 | .... |
| 135 | (this will recursively include the subdirectories) |
| 136 | |
| 137 | Then set the list of the includes required by CND to enable code assistance. |
| 138 | You can get a complete list of include directories by looking at your |
| 139 | build log file and checking what directories are included with "-I" when |
| 140 | the files you're interesed in are built (you can probably devise some |
| 141 | script to generate the list of include files relative to the native |
| 142 | cnd project directory, and the list of defines passed to the compiler) |
| 143 | |
| 144 | For example, on Windows x86, you might have something like this |
| 145 | (a somewhat complete list of awt and 2d native directories on windows): |
| 146 | |
| 147 | ../../src/share/javavm/export; |
| 148 | ../../src/share/javavm/include; |
| 149 | ../../src/share/native/common; |
| 150 | ../../src/share/native/sun/awt/debug; |
| 151 | ../../src/share/native/sun/awt/image/cvutils; |
| 152 | ../../src/share/native/sun/awt/image; |
| 153 | ../../src/share/native/sun/awt/medialib; |
| 154 | ../../src/share/native/sun/awt; |
| 155 | ../../src/share/native/sun/font/bidi; |
| 156 | ../../src/share/native/sun/font/layout; |
| 157 | ../../src/share/native/sun/font; |
| 158 | ../../src/share/native/sun/java2d/cmm/lcms; |
| 159 | ../../src/share/native/sun/java2d/cmm; |
| 160 | ../../src/share/native/sun/java2d/loops; |
| 161 | ../../src/share/native/sun/java2d/opengl; |
| 162 | ../../src/share/native/sun/java2d/pipe; |
| 163 | ../../src/share/native/sun/java2d; |
| 164 | ../../src/windows/javavm/export; |
| 165 | ../../src/windows/native/common; |
| 166 | ../../src/windows/native/sun/awt; |
| 167 | ../../src/windows/native/sun/java2d/d3d; |
| 168 | ../../src/windows/native/sun/java2d/opengl; |
| 169 | ../../src/windows/native/sun/java2d/windows; |
| 170 | ../../src/windows/native/sun/java2d; |
| 171 | ../../src/windows/native/sun/windows; |
| 172 | ../../build/windows-i586/tmp/sun/sun.awt/awt/CClassHeaders; |
| 173 | ../../build/windows-i586/tmp/sun/sun.awt/awt/obj; |
| 174 | ../../build/windows-i586/tmp/sun/sun.awt/awt/obj_gO; |
| 175 | ../../build/windows-i586/tmp/sun/sun.awt/jpeg/CClassHeaders; |
| 176 | ../../build/windows-i586/tmp/sun/sun.awt/splashscreen/CClassHeaders; |
| 177 | ../../build/windows-i586/tmp/sun/sun.font/fontmanager/CClassHeaders; |
| 178 | ../../build/windows-i586/tmp/sun/sun.font/t2k/CClassHeaders; |
| 179 | C:/DevTools/DirectX/DXSDK_Dec06/Include; |
| 180 | C:/devtools/VS2003/SDK/v1.1/include; |
| 181 | C:/devtools/VS2003/VC7/ATLMFC/INCLUDE; |
| 182 | C:/devtools/VS2003/VC7/INCLUDE; |
| 183 | C:/devtools/VS2003/VC7/PlatformSDK/include; |
| 184 | C:/devtools/VS2003/VC7/PlatformSDK/include/prerelease; |
| 185 | |
| 186 | (you can format this into a single line with ';' delimiters and paste it |
| 187 | into the text field instead of entering them one by one) |
| 188 | |
| 189 | Note that most paths are relative to the native project directory - |
| 190 | this helps if you decide to relocate the workspace later. The ones that |
| 191 | aren't relative are paths to external include directories, like those |
| 192 | of the Platform SDK, DirectX SDK. |
| 193 | On Unix platforms these may be directories like /usr/include. |
| 194 | |
| 195 | The parser must know some defines to correctly parse the source files, |
| 196 | these can also be obtained from the log file. For example, on Windows |
| 197 | x86 with debugging enabled, the defines would be something like this: |
| 198 | D3D_OVERLOADS; UNICODE; _UNICODE; WIN32; IAL; _LITTLE_ENDIAN; WIN32; _X86_; |
| 199 | x86; WIN32_LEAN_AND_MEAN; INTERNAL_BUILD; JDK_MAJOR_VERSION='"1"'; |
| 200 | JDK_MINOR_VERSION='"7"'; RELEASE=1.7.0-internal; DEBUG="true" |
| 201 | |
| 202 | (again, format it into a single line with '; ' delimiter - note the |
| 203 | space after ';' - and paste into the corresponding text field) |
| 204 | |
| 205 | Note that the list of include directories will be different on different |
| 206 | platforms and architectures - consult you build log file. |
| 207 | |
| 208 | After the project is created a loaded, you may want to check the list |
| 209 | of include files which weren't found (right-click on the native |
| 210 | project root in Projects exprorer, and select "View failed #include Directives" |
| 211 | from the popup menu. Update the inlcude directories list accordingly. |
| 212 | |
| 213 | You can later create a different configuration for non-debug build, |
| 214 | just make a copy of your current configuration - call it ${arch}-debug |
| 215 | (in the native project's Properties dialog) and remove "DEBUG=true" from |
| 216 | the list of defines. |
| 217 | |
| 218 | Note that with both Java and native projects opened the default |
| 219 | heap size NetBeans starts with might not be sufficient for comfortable work, |
| 220 | so you may need to increase it. You can do it either from the command line |
| 221 | or by editing your ~/.netbeans/dev/etc/netbeans.conf file and adding |
| 222 | something like this: |
| 223 | -J-Xms312m -J-Xmx512m -J-XX:PermSize=128m -J-XX:MaxPermSize=200m |
| 224 | to netbeans_default_options property. |