2010-10-22

Java Console for Linux

From here:


Johan Dahl, 2008-09-01:


A workaround


In gnome: Select System > Settings Sun Java x.x Control Panel

In terminal: jcontrol


  1. Select the tab advanced.
  2. Expand the node "Java-console"
  3. Select show console (default is hide)

Now will the console show up the first time you run an applet. You can keep it open for debugging etc.

If you close the console window must you restart your browser to make it pop-up again.

2010-02-24

GZipOutputStream: Remember to finish() what you start!

Had an interesting experience the other day. I was creating a stream of compressed data using GZipOutputStream and ended up with lots of missing data.

It turns out that data will (may?) not be properly written to the output stream if you neglect to call finish() when you're done pumping data in. Strangely enough, neither flush() nor even close() are sufficient to accomplish this; it's either finish() or you risk having corrupt, incomplete data in your output.

2009-11-01

Eclipse button clicks in Ubuntu 9.10 (Karmic)

Since upgrading to Ubuntu 9.10, I found that some buttons in Eclipse can't be mouse clicked any more. It's usually possible to click them using the space bar, but...

Many thanks to moma for posting a solution on Launchpad!

Start eclipse with
$ cd eclipse
$ export GDK_NATIVE_WINDOWS=true
$ ./eclipse

Or use this one liner:
$ GDK_NATIVE_WINDOWS=true $HOME/eclipse/eclipse

2009-09-26

How to display a directory listing in Google App Engine

Google App Engine is really not meant to serve up a lot of static content; but sometimes you just want to!

If you put a directory full of stuff into your web archive and point your browser at it, AppEngine will tell you there's nothing there. It's possible to change that, though.

The following instructions are for the Java incarnation of AppEngine; I would imagine you can do something equivalent in the Python engine, but I don't know any details.
  • Make sure your directory and its children are marked as "static" in appengine-web.xml :
  • style-span" style="font-family: 'Times New Roman'; font-weight: normal;">Map your directory to Jetty's default servlet within web.xml :
    <static-files>
          <include path="/*.css"/>
          <include path="/favicon.ico"/>
          <include path="/code/**"/>
       </static-files>
    
  • Next, tell Jetty in web.xml to accept directory requests:
    <context-param>
          <param-name>org.mortbay.jetty.servlet.Default.dirAllowed</param-name>
          <param-value>true</param-value>
    </context-param>
    
  • Finally, define Jetty's "default" servlet in web.xml to accept directory requests:
    <servlet>
          <servlet-name>default</servlet-name>
          <servlet-class>org.mortbay.jetty.servlet.DefaultServlet</servlet-class>
          <init-param>
             <param-name>acceptRanges</param-name><param-value>true</param-value>
          </init-param>
          <init-param>
             <param-name>dirAllowed</param-name><param-value>true</param-value>
          </init-param>
          <load-on-startup>0
       </servlet>
    
       <servlet-mapping>
          <servlet-name>default</servlet-name>
          <url-pattern>/code/*</url-pattern>
       </servlet-mapping>
    

  


... and that's more or less it!

2009-09-23

My Eclipse settings

Eclipse is a great Java IDE. There are just a few things I don't like about its default configuration. Fortunately, it's highly configurable.
  • Preferences
    • General
      • Ant
        • Editor
          • Formatter
            • Tab size: 3
            • Use tab character instead of spaces: uncheck.

      • Editors
        • Displaced tab width: 3
        • Insert spaces for tabs: Check.
        • Show line numbers: Check.
        • Text Editors
          • Spelling
            • Enable spell checking: Uncheck.


    • Java
      • Code Style
        • Qualify all generated field accesses with 'this.': Check.
        • Formatter: new profile "carl"
          • Indentation
            • General settings
              • Tab policy: Spaces only
              • Indentation size: 3
              • Tab size: 3


      • Compiler
        • Errors/Warnings
          • Potential programming problems
            • Serializable class without serialVersionUID: Ignore

      • Editor
        • Folding
          • Initially fold
            • Imports: uncheck.


2009-09-03

Substring labels in Blogger

Have you ever tried giving your blog post multiple labels, one of which is a substring of the other?

Example: spring security, spring.

Once Google Blogs has latched on to the longer string, it will move heaven and earth to auto-complete the shorter one for you.

One solution is to add a comma immediately after the short string. Auto-completion won't try to overrule you then.

2009-07-30

Table height = Browser window height WITHOUT quirks mode!

In spite of all the CSS hype, I still occasionally like to use tables to lay out a page. I think there are some layout situations where a table lets you do things CSS layouts don't.

For a long time, I've been despairing about the apparent impossibility of getting a page to fill the browser screen, or a known proportion of it, independently of the user's browser window size and without using JavaScript.

It used to be that a table at 100% height would fill the screen vertically. However, this was a "feature" of the so-called "quirks mode." If you build a Web page with a "proper" DOCTYPE, you hint to the browser that you know how to build standards compliant Web pages, and in return it renders your page more or less rigidly according to the standard.

This is very thoroughly explained by Gary White on the AppTools site .

The good news is, there's a standard compliant workaround. You can use CSS to set the height of the <html> and <body> elements of the page to 100%; their parent is the screen, so they will. Then you can use CSS to set the height of your table to 100%, and it will fill your screen.