You are here: TWiki > Guides Web > Java r12 - 27 Aug 2007 - 10:02 - JesseSuen


Start of topic | Skip to actions

Guides relating to Java Development

Produce a Java core file

$ java -jar Java2Demo.jar & JAVA_PID=$!
$ gcore -o pid_$JAVA_PID.core $JAVA_PID
$ jstack $JAVA_HOME/bin/java pid_$JAVA_PID.core
Alternatively, instead of using gcore to produce the core file, send a SIGABRT signal to the process using:
$ kill -SIGABRT $JAVA_PID

ant: Autogenerate a build version string from SVN in your java program

This assumes you have the svn command in your path.

First, add a line in your source code that will have the build string. This will be modified every time you compile later.

private final static String version = "@(#)<svn_rev> on <date>@";

Then add the following lines to your build.xml, changing the file path to the source of your file containing the version string. In a netbeans project, you would put this in your -pre-compile task:

    <target name="-pre-compile">
        <tstamp><format property="time" pattern="yyyyMMddHHmm"/></tstamp>
        <exec executable="svn" output="build/svn.properties"><arg value="info"/></exec>
        <property prefix="svn" file="build/svn.properties"/>
        <replaceregexp file="src/com/comany/package/YourClass.java"
                       match="@\(#\).*@"
                       replace="@(#)${svn.Revision} on ${time}@"/>
    </target>

Now when you build, everything between the @(#) and @ will be replaced with the automatically generated build string in the ant task.

I usually add a method in the class: public static String getVersion() { return "build "+version.substring(4,version.length()-1); }

So when I call getVersion(), it returns something like: "build 22 on 200704201524"

References:

Swing: setLocation doesn't work

If you are calling setLocation to move a Swing component, and all it does is cause your GUI to flicker while reseting the component back to it's original position, chances are, you are fighting the layout manager. You need to either 1) use the null layout manager, or 2) learn to work with the one you are using.

java.lang.NoSuchMethodError

This error should be obvious, but I'm leaving this here to remind myself: when in doubt, clean and recompile. There is some kind of a class mismatch. If you are positive that the method exists, delete the .class files and force a recompile of all the sources from scratch. It took me a while to figure this one out one night when javac was skipping over a recompile of some classes due to some outdated modification dates of files after a SVN.
Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r12 < r11 < r10 < r9 < r8 | More topic actions
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback