Friday, 12 December 2008

Making Netbeans (text) look a little better on Mac OS X


The defaults in Netbeans are pretty decent, but here are a few changes I like to make. You should create a new profile in Preferences -> Fonts & Colors, to be able to go back to the defaults easily.

The first change I've made is change the default font to Monospace 13. To make fonts look better, switch to the Apple's Quartz rendering engine. To do this add the following
-J-Dapple.awt.graphics.UseQuartz=true

to the netbeans_default_options in the netbeans.conf file. Which can be found at

/Applications/NetBeans/NetBeans 6.5.app/Contents/Resources/NetBeans/etc/netbeans.conf

Textmate also uses bold face for keywords, this is something I really like, and is another change I've made. I've also set the application font to 11, this can be done with
 --fontsize 11 

Friday, 14 November 2008

Java Copying Arrays


There are many ways to copy arrays in Java. I decided to run these benchmarks while writing the buffer pool for a database system I'm writing. The situation (most commonly) arises whenever new pages are brought into the database buffer pool (from disk), their contents need to be copied over the buffer pool, where they are cached. The number of times byte arrays are copied from one place to another is phenomenal, and spread across almost all components of the database, with the buffer manager taking a major portion of these calls.

The code at the end of the post and the benchmark stats below, show us that System.arraycopy is the fastest. The rate at which the time taken increases for the System.arraycopy operation is also a lot lesser than the other methods. I was earlier creating a new object everytime a new database page needed to be cached in memory (yikes!).

performance stats - from 1 to 1 million copy operations -
fill a byte array 1 times.
time taken for for loop fill: 0 ms.
time taken for ac fill: 0 ms.
time taken for clone fill: 0 ms.
time taken for new obj: 0 ms.
fill a byte array 100 times.
time taken for for loop fill: 1 ms.
time taken for ac fill: 1 ms.
time taken for clone fill: 3 ms.
time taken for new obj: 1 ms.
fill a byte array 1000 times.
time taken for for loop fill: 8 ms.
time taken for ac fill: 1 ms.
time taken for clone fill: 5 ms.
time taken for new obj: 2 ms.
fill a byte array 10000 times.
time taken for for loop fill: 99 ms.
time taken for ac fill: 6 ms.
time taken for clone fill: 59 ms.
time taken for new obj: 30 ms.
fill a byte array 100000 times.
time taken for for loop fill: 1085 ms.
time taken for ac fill: 28 ms.
time taken for clone fill: 344 ms.
time taken for new obj: 228 ms.
fill a byte array 1000000 times.
time taken for for loop fill: 11053 ms.
time taken for ac fill: 206 ms.
time taken for clone fill: 2853 ms.
time taken for new obj: 1963 ms.

bug ridden code -

Wednesday, 18 June 2008

Firefox + Mac OS X = rock steady


Firefox 3 is out its pretty decent, been using it for a day or two and its great. It is a lot snappier and has a mac(ish) look and feel. I'm not sure about the claims on drastically lower memory usage, its still at about 280 MB main memory usage for about 145 tabs. Yes! 145. Thats about the same as firefox 2 took. And just for the record the screenshot below shows firefox 2 with 401 tabs. Yes! 401. That's the maximum I've reached, and they're all legit useful tabs opened over a long duration. If I remember correctly 401 tabs took about 350 MB space and CPU usage hovered around the 4 - 5 % mark. Like the title says rock steady.


Firefox 2, 401 Tabs

Tuesday, 3 June 2008

Converting Bytes to Ints and back

//convert a byte to int and back
class ConvByteInt {
public static void main(String[] args) {
//signed byte
byte s_byte1 = Byte.parseByte(args[0]);
byte s_byte2 = Byte.parseByte(args[1]);
System.out.println("the bytes are: " + s_byte1 + ", " + s_byte2);
//unsigned ints (logically, -1 EOS)
int u_int1 = s_byte1 >= 0 ? s_byte1 : s_byte1 + 256;
int u_int2 = s_byte2 >= 0 ? s_byte2 : s_byte2 + 256;
System.out.println("the integers are: " + u_int1 + ", " + u_int2);
//convert them back, casts
byte a = (byte) u_int1;
byte b = (byte) u_int2;
System.out.println("the bytes are: " + a + ", " + b);
//convert them back, no casts
//representation 0 - 255 (unsigned ints)
//does NOT check boundary conditions
//are the bit operations even needed ??
byte c = (byte) ((u_int1 & 0x000000FF) <= 127 ? u_int1 : u_int1 - 256);
byte d = (byte) ((u_int2 & 0x000000FF) <= 127 ? u_int2 : u_int2 - 256);
System.out.println("the bytes are: " + c + ", " + d);
}
}

sample out-

17864397:io anujseth$ java ConvByteInt 43 -12
the bytes are: 43, -12
the integers are: 43, 244
the bytes are: 43, -12
the bytes are: 43, -12

Friday, 30 May 2008

Using SVN on your Mac


Svn is pre-installed on leopard, and should already be on your path. The steps that follow setup a repository and test it using Netbeans.

We need to create our repository (local) first,

17864397:dist anujseth$ svnadmin create ~/Desktop/research/SVNRep
17864397:dist anujseth$ ls ~/Desktop/research/SVNRep/
README.txt conf dav db format hooks locks


The above creates our repository named SVNRep in the research folder on the users desktop. We then import our project(s) into this repository.

17864397:dist anujseth$ svn import /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS file:///Users/anujseth/Desktop/research/SVNRep/DFS -m "Initial Import"Adding         /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/ForwardBoundPeerFactory.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/BackwardBoundPeer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/PeerFactory.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/RandomBoundPeer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/ForwardBoundPeer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/OverlayGenerator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/LookupSimulator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/BackwardBoundPeerFactory.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/Peer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/simulator/RandomBoundPeerFactory.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/logging
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/logging/FileLogger.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/logging/Logger.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/logging/CentralizedGatherer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/logging/CentralizedGathererTest.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/logging/StatisticsGatherer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/logging/LoggerException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/DataGenerator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/Experiment.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/BenchmarkGenerator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/proc
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/proc/VisitConsolidator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/proc/Consolidator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/SingleSetupExperiment.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/SkewedBenchmarkGenerator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/CommandGenerator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/ExperimentalShell.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/BenchmarkException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/benchmark/CommandParser.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/ByteRepresentable.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/HashUtilities.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/RoutingTable.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/Convert.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/netgen
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/netgen/NetworkGenerator.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/AbstractNetObject.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/FileTypeException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/DummyDBClient.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/DBPeerClientTest.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/LocalDB.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/DBPeerTest.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/DBPeer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Deletion.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/LinkedPage.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/DBException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/LayoutManager.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Lookup.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Insertion.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Catalog.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/.old
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/RelationDescriptor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Layout.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/PageAccessException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Command.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Record.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/FileType.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Scan.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/LocalDBServer.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Key.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/Payload.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DBTreePage.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DBTreeCursor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DLogicalIDKey.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DExtHashSlottedPage.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DBTree.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/OutOfRoomException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/NullCursor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DExtHashFile.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DBPlusTree.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/Page.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DArrayFileLayout.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DCursor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DArrayFile.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DHashSlottedPage.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DFile.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DHashFileRelationDescriptor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/OutOfBoundsException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DDynamicHashFileRelationDescriptor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/RequestDispatcher.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DCursorException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DFileException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/LinkedPage.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DExtHashFileRelationDescriptor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DBPlusTreeRelationDescriptor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DLinearCursor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DSlottedPage.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DArrayFileRelationDescriptor.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DSlottedFile.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/NullPayload.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DHashFile.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/dio/DDynamicHashFile.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/DBNode.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/db/LayoutException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/InsufficientIDsException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/Node.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/LogicalID.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/fs
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/fs/NetObjectCache.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/fs/CacheException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/fs/NetObjectManagerException.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/fs/NetObjectManager.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/fs/FileUtilities.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/PhysicalID.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/NOTest.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/framework/NetObject.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/util
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/util/ShutDownThread.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/util/Triplet.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/util/Pair.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/src/peer/util/Args.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/p2p/build.xml
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/toAsk.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/toDo.java
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts/cleanup.sh
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts/gensetups.sh
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts/servers.txt
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts/clsetup.sh
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts/cleanupall.sh
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts/killall.sh
Adding /Users/anujseth/Desktop/coursework/MScDiss/QueryDFS/scripts/go.sh

Committed revision 1.
17864397:dist anujseth$


The "Initial Import" string adds meta information to your action, and can be anything.

You can similarly use command line options to manage your code (checkout etc.) , we're just going to switch to Netbeans directly. All you need to do is go to Versioning -> Subversion, and add the path to your repository and follow the simple GUI instructions, ours in this case is file:///Users/anujseth/Desktop/research/SVNRep.

Infact if you want you can just do step one (create your repository) and directly import your projects from netbeans itself, simply right clicking your project and selecting import into subversion from the versioning menu.

Tuesday, 27 May 2008

Netbeans 6.0 and Mac OS X (part 2)


(This post was originally written circa Dec. 2007)

To fix the dock icon problem mentioned in the previous post and to run Netbeans directly by clicking the dock icon, with the Metal look and feel, you need to edit the netbeans.conf file.
17864397:etc anujseth$ pwd
/Applications/NetBeans/NetBeans 6.0.app/Contents/Resources/NetBeans/etc
17864397:etc anujseth$ ls -l
total 24
-rw-r--r--  1 root  admin   205 26 Nov 17:43 netbeans.clusters
-rw-r--r--  1 root  admin  1093 26 Dec 20:44 netbeans.conf
-rw-r--r--  1 root  admin  1047 26 Dec 20:44 netbeans.conf_orig_jdk_home
17864397:etc anujseth$ sudo vi netbeans.conf
Password:
17864397:etc anujseth$ 

This is what my file looks like after editing.
# ${HOME} will be replaced by JVM user.home system property
netbeans_default_userdir="${HOME}/.netbeans/6.0"
# Options used by NetBeans launcher by default, can be overridden by explicit
# command line switches:
#netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true"
#---------------------------------
#---------------------------------
netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-XX:MaxPermSize=200m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true --laf javax.swing.plaf.metal.MetalLookAndFeel --fontsize 11"
#---------------------------------
#---------------------------------
# (Note that a default -Xmx is selected for you automatically.)
# If you specify the heap size (-Xmx) explicitely, you may also want to enable
# Concurrent Mark & Sweep garbage collector. In such case add the following
# options to the netbeans_default_options:
# -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled
# (see http://wiki.netbeans.org/wiki/view/FaqGCPauses)
# Default location of JDK, can be overridden by using --jdkhome :
netbeans_jdkhome=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
# Additional module clusters, using ${path.separator} (';' on Windows or ':' on Unix):
#netbeans_extraclusters="/absolute/path/to/cluster1:/absolute/path/to/cluster2"

You basically need to add
--laf javax.swing.plaf.metal.MetalLookAndFeel --fontsize 11

, with whatever font size you want, to the
netbeans_default_options

value. You can similarly use the GTK or Windows look and feels etc.
--laf javax.swing.plaf.metal.MetalLookAndFeel
--laf com.sun.java.swing.plaf.motif.MotifLookAndFeel
--laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel
--laf com.sun.java.swing.plaf.windows.WindowsLookAndFeel
--laf javax.swing.plaf.metal.MetalLookAndFeel -J-Dswing.metalTheme=steel

The last one will give you the original (called Steel) look for the Metal Look and Feel, by default the cross platform Metal Look and Feel uses 'Ocean' (yes! it is mind-numbingly confusing). The windows LAF doesn't seem to work, I'm not sure to be honest but it looks a lot like the ocean one.

Monday, 26 May 2008

Netbeans 6.0 and Mac OS X


(This post was originally written circa Dec. 2007)

Netbeans 6.0 is out, it looks really good, some of the code editor improvements are brilliant (actually I really like the color scheme : ) ). Thats besides the point, there is a major problem that I have with using Netbeans 6.0 on Mac OS X 10.5. The problem is that the menu-bar is just endless and as a result covers most of my stat-counters etc. So, how does one fix it, simple switch to the metal LAF. Some of us, me actually, like the blueish Java metal LAF. So to do this just run netbeans with a few command line parameters, like so,
/Applications/NetBeans/NetBeans\ 6.0.app/Contents/MacOS/netbeans --laf
javax.swing.plaf.metal.MetalLookAndFeel --fontsize 12

This, launches Netbeans 6.0 (provided you have chosen the default installation location) with the metal look and feel, and a font size of 12 (the default is 11). As can be seen in the screenshot, a new dock icon is launched however and I haven't figured out how to link the Netbeans.app one and the one that launches from the using the binary file.

In general, to use the Metal look and feel with your Java applications on Mac OS X, simply launch them with the following command line parameter
-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel

for example,
java -Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel -jar
/Developer/Examples/Java/JFC/SwingSet2/SwingSet2.jar

launches the swing set example, with the metal look and feel. This of-course cannot be used with the /jdkhome/bin commands, jconsole for example. To change your default settings that is to have applications launch with the Metal LAF by default, you need to edit the swing.properties file.
17864397:~ anujseth$ cd /Library/Java/Home/lib
17864397:lib anujseth$ sudo vi swing.properties

The default is set to Apple's Aqua LAF and can be changed accordingly, for example,
#the java metal LAF
swing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel
#apple default setting
#swing.defaultlaf=apple.laf.AquaLookAndFeel

this is what my swing.properties file looks like.

Thats about it, I wrote this because I could not really find any such document on the Metal LAF, ah well maybe I'm the only crazy one who prefers it to all native-ish LAF's. Dare I say, Happy Hacking!, :).