Preskočiť na hlavný obsah

Príspevky

Zobrazujú sa príspevky z dátumu 2010

How to use Java Jar Tool?

If you need to package your classes in a jar file use jar command line utility. Creted Jar file can be used in class path. creates new JAR: jar cf target.jar inputfiles: It is used to to view all the files of the JAR: jar tf somefile.jar to run a JAR if the manifest file is present in the JAR. The manifest file must contain the information of the class file having main method: java -jar app.jar to extract the JAR: jar xf somefile.jar

Heaven or Hell?

A Java programmer finds himself in front of a final committee that decides whether he should go to Heaven or stay in Hell for the rest of the time...

Some tips/hints on extra JVM parameters

Use the JVM options -XX:+TraceClassloading and -XX:+TraceClassUnloading to see what classes are loaded/un-loaded in real-time. If you have doubts about excessive class loading in your app; this might help you find out exactly what classes are loaded and where. Use -XX:+UseParallelGC to tell the JVM to use multi-threaded, one thread per CPU, garbage collection. This might improve GC performance since the default garbage collector is single-threaded. Define the number of GC threads to use with the -XX:ParallelGCThreads={no of threads} option Never call System.gc(). The application doesn't know the best time to garbage-collect, only the JVM really does. The JVM option -XX:+AggressiveHeap inspects the machine resources (size of memory and number of processors) and attempts to set various heap and memory parameters to be optimal for long-running, memory allocation-intensive jobs.

How to install Oracle JRockit java for gentoo

# instal JRockit into /opt/jrockit-jdk-bin-4.0.0 ./jrrt-4.0.0-1.6.0-linux-ia32.bin # make link for installed jrr jvm ln -s /opt/jrockit-jdk-bin-4.0.0 /usr/lib/jvm/jrockit-jdk-bin # create/customize config for jrockit vi /usr/share/java-config-2/vm/jrockit-jdk-bin # use java-config -S n to activate jvm # Example for /usr/share/java-config-2/vm/jrockit-jdk-bin VERSION="JRockIt 4.0.0." JAVA_HOME=/opt/jrockit-jdk-bin-4.0.0 JDK_HOME=${JAVA_HOME} JAVAC=${JAVA_HOME}/bin/javac PATH="${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin" ROOTPATH="${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin" LDPATH="${JAVA_HOME}/jre/lib/i386/:${JAVA_HOME}/jre/lib/i386/native_threads/:${JAVA_HOME}/jre/lib/i386/xawt/:${JAVA_HOME}/jre/lib/i386/server/" #MANPATH="/opt/sun-jdk-1.6.0.18/man" PROVIDES_TYPE="JDK JRE" PROVIDES_VERSION="1.6" # Taken from sun.boot.class.path property BOOTCLASSPATH="${JAVA_HOME}/jre/lib/resources.jar:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_H

limit of 64kB per Java method

This is not optimization tip, but... do you know...? that Java (JVM) limits the amount of code to 64kB per Java method. Sometimes, as the JSPs grow larger, there is a possibility of hitting this limit.

.Net vs. Java programmers Joke

A group of 4 Microsoft .NET programmers and a group of 4 Java programmers are going on a train to an expo. The MS programmers buy a ticket each, and then watch the Java programmers proceed to buy one ticket between them. The MS programmers are intrigued and when they get on the train, they watch the Java programmers to see what they do when the guard comes to check the tickets. It turns out that, before the guard comes, they all cram into the toilet. The guard knocks on the door, and asks for the ticket. The guard takes it from under the door, and slides it back. The MS programmers are all impressed, so on the way back, they buy only one ticket. Only to watch the Java folks get on the train without buying a ticket at all. When they get on the train, the MS people cram into the toilet, as they saw the Java folks on the earlier journey. The Java programmers then knock on the door, and say "Ticket please". The MS programmers slide the ticket under the door, as they saw the

Java Exceptions Joke

A bunch of 17 year olds - ClassCast, IllegalArgument and ArrayOutOfBounds - decide to take their chances, and try to get served at the bar. The Bartender takes one look at them, and asks them for ID. ClassCast hands over his fake ID, IllegalArgument hands over his brother Throwable's ID, but ArrayOutOfBounds doesn't have any fake ID. The Bartender says "Sorry guys, you'll have to leave unless I can see some ID". ClassCast pleads with the barman "can't you just bend the rules for us?" and the barman says "Sorry, no Exceptions".