Link from log console output to a line of code in IntelliJ

Whilst playing around with some code analysis I thought it would be useful to be able to output a hyperlink back to a line of code in the IDE console. As it happens, you can “Trick” IntelliJ to do this with the following log statement:

    public void canClickOnAFileInTheConsoleAndGoToTheLineOfCode() {“Check it at %s. (”,
            getClass().getName(), getClass().getSimpleName(), 15));

The pattern it seems to match is something like at {classFullName}.{identifier}({classSimpleName}.java)

classFullName has to be a valid class name.
identifier is usually used for the method name, but it can be anything. The full stop is nescessary. So in the example above, I put a space in there and so it reads like a sentance.

Anyone know a another way to do this?


Actually it seems that you can get something similar if you output a full path name, e.g.:

    File f = new File(“./src/test/resource/testfiles/level_01/level_01_01/file_01_01_A.txt”); + “:” + 34);

This will create a link in the output window to the line of the file. Nice.


Colorised Build Success Message

My current project has a neat trick we picked up where the build has a red or green banner at the end when you run it locally to give good feedback about the build status. I’m not sure who originated it, but thanks!

I just had to tweak it a bit to get it working on OS X so I thought I would document the trick here. - OS X

CMD=”./tools/ant/bin/ant -lib ./asl/lib/jdepend $@”
echo “Running command [${CMD}] …”
if [ “$?” -ne 0 ]; then
    echo -e “`tput setab 1`  `cat ./ci/failed.txt` `tput setab 0`”
    exit 1
    echo -e “`tput setab 2`  `cat ./ci/passed.txt`  `tput setab 0`”
    exit 0

This assumes you have two supporting files ./ci/passed.txt and ./ci/failed.txt which contain the message. You can generate messages to your taste here.

I have provided the files in this example here :



It has also been run under Ubuntu where the following works (it didnt work on OS X which is why I adapted it), but the tput should also work on Ubuntu. I’ve not explicitly tested this one!

if [ “$?” -ne 0 ]; then
    echo -e “\E[30;41m”
    cat ./ci/failed.txt
    echo -e “\E[0m”
    exit 1
    echo -e “\E[30;42m”
    cat ./ci/passed.txt
    echo -e “\E[0m”
    exit 0

Under windows you can actually make the entire screen of the terminal change color:

run.bat - WINDOWS

CALL tools\ant\bin\ant %*
color 4F
color 2F
color 07

Install Oracle XE 10g On OS X with VMWare Fusion

Oracle HQ

Oracle don’t yet provide a native OS X installer for XE but you can install it on a virtual machine running under OS X.

I found a very detailed article here [1] but also found it quite hard to follow, so thought I would post my own experience here, referring back to that one where appropriate.

First you need VMWare Fusion

I have installed Windows XP SP 2 on there.

The installation of Fusion and XP was pretty straightforward, just point and click. Once the windows guest machine is set up, fusion should prompt you to install VMWare tools which makes the graphics look much better. It will also ask you to install McAffee anti virus (its a free 12 month trial) which I did.

According to [1], it is important to set the computer name. In my case I set this to be “winxp-guest” (right click My Computer).

Next thing is to get the networking set up correctly. You have 3 options with VMWare Fusion:

  • NAT – share the network adapter with the host machine
  • BRIDGED – VM appears to be a seperate machine to the host
  • PRIVATE – VM is only available within the host machine and not on the wider network

PRIVATE networking means your VM cannot connect to the internet, so the best option is NAT

When you change your network settings you need to renew your network config:

ipconfig /release
ipconfig /renew

You should see your IP address like this:

C:\Documents and Settings\Administrator>ipconfig /renew
Windows IP Configuration
Ethernet adapter Local Area Connection:
       Connection-specific DNS Suffix  . : localdomain
       IP Address. . . . . . . . . . . . :
       Subnet Mask . . . . . . . . . . . :
       Default Gateway . . . . . . . . . : 192.168.xx.xx

In order to be able to connect to your guest machine from outside, you need to configure firewalls…

Initially, I disabled McAffee. Once I got everything working, I re-enabled Mcaffee and found that when I tried to access using SqlDeveloper it automatically asked me if I wanted to allow this program.

To setup the windows firewall, you need to go to Control Panel -> Windows Firewall -> Exceptions -> Add Port…
You’ll need to do this twice, one for http access to the admin tool (8080) and one for client access (1521 which is the default)

You also need to select Advanced -> ICMP -> Allow incoming echo request if you want to be able to ping it.

From the host:

64 bytes from icmp_seq=0 ttl=128 time=0.290 ms
64 bytes from icmp_seq=1 ttl=128 time=0.498 ms

You should also setup your hosts file on the host computer:

sudo vi /etc/hosts
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##       localhost broadcasthost
::1             localhost
fe80::1%lo0     localhost winxp-guest winxp-guest.localdomain

The localdomain part I found out from installing apache. Note, I also ran “Network ID” wizard from the My Computer-> Computer Name screen, not sure if that made a difference.

Now you can ping winxp-guest

To check that everything is in order, I installed apache on the guest

I picked httpd-2.2.15-win32-x86-no_ssl.msi and within a few moments I can navigate to http://winxp-gueston the guest machine and see an apache “It Works!” page.

I can also do this from my host machine, so networking is all good.

In the reference it mentions setting up the windows hosts file aswell on the guest machine, this is so that everything works on the guest machine with the tnsnames.ora file (it get generated to point to whatever the hostname of your machine is). It is not important to connect from the host machine.

# For example:
#          # source server
#              # x client host       localhost winxp-guest winxp-guest.localdomain

Next install Oracle XE itself. The only thing required to enter here is a password, which you will later use to log in to the web interface with the user “SYSTEM”

Once installed, you can launch the home page and log in as SYSTEM. The first thing to do is to change “Administration->Http Access” which will allow computers outside the machine to access the admin console.

Then you can try it out using sqlplus. I found there was a mistake in the Environment PATH variable – it had referred to the bin directory as “bin” but in windows it was actually “BIN”. Changing it made it work for me.

sqlplus SYSTEM/{password}@XE
SQL> create table foo (bar number, baz varchar(255));
SQL> insert into foo VALUES (2, ‘blah’);
SQL> select * from foo;
SQL> drop table foo;

Brilliant. You have an oracle database.

The connection XE is from your tnsnames.ora file which lives (in default install) at C:\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN

and contains:

XE =
    (ADDRESS = (PROTOCOL = TCP)(HOST = winxp-guest)(PORT = 1521))

Notice the hostname in here. Presumably if you wanted to change this you could update this file and the computer name and your hosts file.

Next step is to try accessing from the host machine.

I used Oracle SQLDeveloper

I used a jdbc connection string of jdbc:oracle:thin:@winxp-guest:1521:xe

Note that as long as you update /etc/hosts on the host machine, you can call the computer whatever you like (e.g. oraclexe)

Something you might need to do is create a new tablespace. You can do this through the oracle administration console. Go to “home” and then SQL and you can execute sql like this:

create tablespace  datafile ‘/ORACLEXE/ORADATA/XE/{table_space_name}/{table_space_name}.dbf’ size 500m;