Welcome, please login or register

What is java.lang.OutOfMemoryError: PermGen space

While developing an Eclipse based application I encountered a troubling error java.lang.OutOfMemoryError: PermGen space.

It doesn’t help to allocate more more heap memory with -Xmx.

This error is caused when the Garbage collector’s Permanent Generation fills up. The garbage collector first fills up the Young Generation and then a Minor Collection is done, some objects that were not collected are put in next generation, the Tenured Generation. After it fills up a Major Collection is performed. Then there is the third generation which is the Permanent Generation. Especially applications with a lot of classes may fill up this part of the heap.

To fix this problem the default permanent generation heap segment can be increased from 64M to something else. I used 128M which worked great.

-XX:MaxPermSize=128m

Cisco VPN Error 51: Unable to communicate with the VPN subsystem

You may get this error with a Cisco VPN client on a Mac when network adapters disappear and reappear. To fix it run the following:

sudo SystemStarter restart CiscoVPN

How to force Eclipse app to pick Java version on Mac?

In a situation where the Mac OS X default Java is not the one you need for your app to use there is a way to force it to pick the version you want.

* Right click on your Eclipse.app in the Finder
* Select “Show Package Contents”
* Go to Contents/
* Open Info.plist in an editor
* Add the line
<string>-vm</string><string>/System/Library/Frameworks/
JavaVM.framework/Versions/1.6.0/Commands/java</string>

for setting Java 6

Otherwise you can change the default version of java as well in the Java properties. I have noticed a bug in it. I had the right setting, but it only took effect after I moved the versions around a bit . On one MacBook it still didn’t open the application with the right Java version so it had to be forced like described above.

How to determine Java version from .class file

The first 4 bytes is the magic number CAFEBABE. Then comes 2 bytes with the minor version and then the major version.

The major version number means:
J2SE 6.0 = 50 (0×32 hex),
J2SE 5.0 = 49 (0×31 hex),
JDK 1.4 = 48 (0×30 hex),
JDK 1.3 = 47 (0×2F hex),
JDK 1.2 = 46 (0×2E hex),
JDK 1.1 = 45 (0×2D hex).

For example if the byte code Hex starts with

CAFEBABE00000032

it means it is J2SE 6

For more details see http://en.wikipedia.org/wiki/Class_(file_format)

Mac OS X commands

Here follows an incomplete collection of a couple Mac OS X commands. Just open up Terminal.app, and try them out.

If you are familiar with UNIX you are lucky since most UNIX commands work.

ifconfig lists the IP address and a lot more network information. To keep the output shorter try ifconfig | grep inet.

locate finds files

pico opens a text editor in the shell

df displays how much free disk space is available

mkdir -p x/y/z creates all directories at once

pkgutil –pkgs list installed packages, to get details use pkgutil –pkg-info <package-name>

!$ refers to the last parameter and can be reused in the next command

find . -name *.xml | xargs grep MyString finds a string “MyString” in files in or below the current dir

find . -type f -print0 | xargs -0 chmod a-w changes write permissions recursively. Works if the files contain spaces slashes etc. Use -type d if you need to change the dirs instead.

Here are some additional commands: http://ss64.com/osx/

Non shell commands:

Capture a screen shot:

  1. To capture the entire desktop, press Command-Shift-3. The screen shot will be automatically saved as a PNG file on your desktop
  2. To copy the entire desktop, press Command-Control-Shift-3. The screen shot will be placed on your clipboard for you to paste into another program.
  3. To capture a portion of the desktop, pressCommand-Shift-4. A cross-hair cursor will appear and you can click and drag to select the area you wish to capture. When you release the mouse button, the screen shot will be automatically saved as a PNG file on your desktop. (The file is saved as PDF in Mac OS 10.3 and earlier.)
  4. More screen shot possibilities: here and here

Show hidden files like files starting with a dot

defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder

And to revert back set it to FALSE

What is Google Goggles?

Google Goggles uses pictures taken with an Android phone to search the web.

It uses Google’s image search and OCR for text. Using the text if it is available it makes a google search. Otherwise it uses an image search. It uses GPS data to enhance the accuracy for outdoor photos.

It doesn’t even need to take a photo for local business information. Just point the phone at a store and it will display it’s name on the screen in real time. Then you can click on the displayed name to get the search results. It uses GPS and Compass to enhance the search.

This is available in the Nexus One phone and as a free app at the Android marketplace.

It is said to work well with objects like business cards, paintings, landmarks, wine, books, and logos, but it’s not great with things like food, animals, and plants.

I’m just waiting for when it will allow you to contribute to a 3D model of the world. This 3D model should of course be integrated with Google Earth and Street View and allow a first person navigation with a game engine. One step further is to add real time video input to the model and even output from the model or virtual world (Hello Matrix). Imagine a virtual world interacting with the real. People could see into the virtual world for example if it is projected on a real wall and interact with the avatars :) .

What is TCP/IP?

TCP/IP is a large collection of different communication protocols based upon the two original protocols TCP and IP:

  • TCP (Transmission Control Protocol) communication between applications
  • UDP (User Datagram Protocol) simple communication between applications
  • IP (Internet Protocol) communication between computers
  • ICMP (Internet Control Message Protocol) for errors and statistics
  • DHCP (Dynamic Host Configuration Protocol) for dynamic addressing
  • HTTP (Hyper Text Transfer Protocol) web browser to server
  • SNMP (Simple Network Management Protocol) administration of networks
  • NTP (Network Time Protocol) synchronize the time between computers
  • SMTP (Simple Mail Transfer Protocol) transmission of e-mails
  • IMAP (Internet Message Access Protocol) storing and retrieving e-mails
  • POP (Post Office Protocol) downloading e-mails

TCP Uses a Fixed Connection and IP is Connection-Less. When an IP packet is sent from a computer, it arrives at an IP router. The IP router is responsible for “routing” the packet to the correct destination, directly or via another router.

TCP/IP is TCP and IP working together. TCP takes care of the communication between your application software (i.e. your browser) and your network software. IP takes care of the communication with other computers. TCP is responsible for breaking data down into IP packets before they are sent, and for assembling the packets when they arrive. IP is responsible for sending the packets to the correct destination.

Each computer must have a unique 4 byte  IP address. A domain name corresponds to an IP address and makes it easier to remember. It is translated by a DNS to an IP address.

A browser uses TCP/IP to access a server. A server uses TCP/IP to send HTML back to a browser. An e-mail program uses TCP/IP to connect to the Internet before sending and receiving e-mails using POP, SMTP and IMAP.

IP is at layer 3 in the OSI stack:

7.Application
6.Presentation
5.Session
4.Transport TCP, UDP
3.Network IP
2.Datalink Ethernet
1.Physical

There are two sets of rules for subnetting TCP/IP networks. The original set of rules can be found in RFC 950, and the new set of rules can be found in RFC 1812.

A good analogy for IP addressing and packet forwarding (routing) is the snail mail analogy. Consider an IP packet to be an envelope containing data, and having an address on the front. Every TCP/IP-enabled network interface can be compared to a mailbox. Every mailbox (interface) has an IP address. The four bytes of an IP address can be compared to the state, city, street, and house number fields on the front of a snail mail envelope. A router in this analogy is a post office, that sorts and forwards mail based on the address on the envelope (packet header.) If the address is on the same street (based on the subnet mask,) the envelope (packet) is sent directly to the destination mailbox (interface) via local courier (Ethernet?). If the address is determined to be on another street, or in another city or state, the envelope (packet) is delivered via local courier (Ethernet?) to the street’s post office (router), where the postal workers (routing software) sort and forward mail based on established post office sorting procedures (routing tables.)

References:

http://www.w3schools.com/tcpip/tcpip_intro.asp

http://www.ipprimer.com/section.cfm

http://encyclopedia2.thefreedictionary.com/OSI+model

http://www.faqs.org/rfcs/rfc1812.html

What is x86 virtualization?

x86 virtualization is a software based emulation of x86 processor hardware. On some hardware there is installed some OS, for example 32 bit Linux. Then there is a virtualization program that runs on it that emulates another OS, for example Windows XP.

There are a number of available virtualization programs, for example:

  • VMware was the first but has some performance overhead
  • Virtual Server, VirtualPC and Hyper-V is by Microsoft
  • KVM is open-source and uses hardware-assisted virtualization
  • Xen uses paravirtualization or hardware-assisted virtualization

Paravirtualization means that the guest OS is ported and some hard parts skipped.

Hardware-assisted virtualization assumes that the host system supports it, which for example AMD-V and Intel VT does and can give very high performance.

How do I get Java 6 for Mac OS X?

Unfortunately decaf for your old Power PC Mac

For a PowerPC you can’t.

For Snow Leopard you just get it from Apple at  http://support.apple.com/downloads/Java_for_Mac_OS_X_10_5_Update_1