30 September 2008

Black Text, Please

It makes my eyes water to read grey text on a white background, so much so that I was motivated to learn how to use the Greasemonkey Ain't It Readable script to set text in <p> elements to black. Using Greasemonkey just to set a single CSS attribute was an overkill, so I turned it off and wrote this rule for the Stylish add-in: p { color:black; }.

See Also

27 September 2008

GDB 6.8 in NetBeans 6.1 Hangs

When trying to debug a C++ program in NetBeans 6.1 using MinGW gdb 6.8, gdb would hang when starting (and cause NetBeans to hang as well). My workaround was to restart NetBeans, open the debug window (see Windows / Debug menu item) and delete all breakpoints.

This thread gdb 6.8.0 debug process in netbeans 6.1 hangs? shows where to find gdb's log file to help solve the problem (in Vista, it's C:\Users\<user>\AppData\Local\Temp\gdb-cmdsX.log).

17 September 2008

Cannot Open EAP (MDB) File

When I tried to open an old EAP file, EA displayed this error message: An Error has Occurred: The Microsoft Jet database engine cannot open the file '…'. It is already opened exclusively by another user, or you need permission to view its data.. I copied the EAP file to my hard disk and tried to open it again but EA displayed the same message. Maybe there's an internal lock on the file?

An EAP file is a Microsoft Access database, so I renamed the extension from '.eap' to '.mdb' and opened it in MS-Access to see if I could unlock the file. When MS-Access displayed this warning: The database '…' is read-only., I wondered if the solution was as simple as just removing the 'Read-only' attribute from the file. Tried it and now I can open my EAP file.

13 September 2008

NetBeans JUnit "Forked Java VM exited abnormally"

While trying to run a test case for a Java program in NetBeans using JUnit, my test suite failed and I found this error:

Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
junit.framework.AssertionFailedError
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)

For some reason, NetBeans could not start a new virtual machine (I guess that's what the 'fork' means). I used NetBeans to debug the Ant test target and found in the nbproject\build-impl.xml file …

    <target name="-init-macrodef-junit">
        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
            <attribute default="${includes}" name="includes"/>
            <attribute default="${excludes}" name="excludes"/>
            <attribute default="**" name="testincludes"/>
            <sequential>
                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
…

replacing fork="true" with fork="false" gave a more meaningful error message:

Exit from within execution engine, normal
org.netbeans.core.execution.ExitSecurityException: Exit from within execution engine, normal
…
        at org.netbeans.core.execution.SecMan.checkExit(SecMan.java:66)
        at org.netbeans.TopSecurityManager.checkExit(TopSecurityManager.java:145)
        at java.lang.Runtime.exit(Runtime.java:88)
        at java.lang.System.exit(System.java:906)
        at PrintLineNumber.Main.main(Main.java:16)
        at PrintLineNumber.MainTest.testMainNoArguments(MainTest.java:47)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)

So, the NetBeans security manager does not allow my program to call System.exit(1), which is fair enough, otherwise (I guess) NetBeans would exit as well.

The location of the problem is in the test code below, created by NetBeans, which calls the main() method of my application:

44  public void testMain() {
45    System.out.println("main");
46    String[] args = null;
47    Main.main(args);
48  }

And here is the code that was tripping JUnit:

15      if (args == null || args.length != 2) {
16        System.exit(1);
17      }

My code was checking if the argument list is null, but that should never happen in normal use because the Java launcher always calls main() with a String array, not null. I removed the test for a null args and allowed a NullPointerException to be thrown. Then I added a test case for this situation:

  @Test(expected=NullPointerException.class)
  public void testMainNullArguments() {
    Main.main(null);
  }

Now, JUnit runs my test suite to completion!

12 September 2008

ORA-24324, ORA-24323 and ORA-28547 Workaround

On a Windows notebook, one of our consultants couldn't connect to his local Oracle database. We deleted the database, then when we try to create a new database using Database Configuration Wizard, the wizard would report the following errors: ORA-24324, ORA-24323 and ORA-28547. Then we remembered that we recently installed software for a USB-based 3G modem, so we plugged in the modem and now Oracle works again! Don't know why at the moment, but we guess that the absence of the new network adapter was confusing Oracle.

Later ߪ it seems that all that is required is to ensure that the modem adapter software is loaded into memory when Windows is restarted (it was originally disabled).

07 September 2008

Minor Bug Fix in Conquest Game

A game that I play, Conquest, occasionally crashes because of some bad input, so I ported it from Borland C to Visual C++ to compile and debug it. Some minimal changes required were:

  • Use double instead of float types.
  • Reimplemented clrscr() and gotoxy() functions using Windows Console functions.
  • Change function names in proto.h: _cprintf(), _getch() and _putch().

In the VC++ debugger, I found that the problem occurs in the get_token() function, which parses the user's input. For some reason, when I type too fast, an illegal character is entered. Changing the get_line() function, called by get_token(), to only allow 7-bit ASCII characters in the input, seems to fix the problem.

See Also

06 September 2008

Change Default Text Font in Eclipse

Here's how to change the default font used by all the text editors in the Eclipse IDE:

  1. Select menu item Window / Preferences.
  2. In Preferences dialog, select node General / Appearance / Colors and Fonts.
  3. In Colors and Fonts pane, select node Basic / Text Font.
  4. Press Change… button to open the font selection dialog, select the font that you like, then close that dialog.
  5. Press Apply button.

Text editors that have specific fonts selected won't use the font selected in the Text Font property. If you want always use the default text font, select the text editor's font property in the Preferences dialog, then press the Reset button. You should see the text editor's font property change from … (overrrides default: Text Font) to … (set to default: Text Font).