Skip navigation

To counteract my relative lack of skill with java, I use the smartest IDE I can find; Intellij IDEA. It is really helpful in getting syntax right (and lots of other things, too). Unfortunately, the CS labs do not have it installed, and at 170 MB, I can’t spare enough space to put it on my account.

To solve this problem, I have tried the following solutions:

  • VNC using X11VNC
  • X forwarding using ssh -X (with and without -C)
  • NX

Unfortunately, although my ping time is 6 ms, both VNC and X forwarding are terribly slow. NX has some issues with my ssh configuration, and I have been unable to get it to work properly.

Today I built a little script to solve the lack of this excellent editor. Here is the first iteration:

#!/bin/bash

scp -r username@bart:/tmp/idea-7590 /tmp

if [ -f /tmp/idea-7590/bin/idea.sh ]; then
ls /tmp/idea-7590
else
scp -r username@my.computerdomain.net:/home/username/idea-7590 /tmp/
scp -r /tmp/idea-7590 username@bart:/tmp/ &
fi

export JDK_HOME="/opt/jdk1.6.0_03"
/tmp/idea-7590/bin/idea.sh &

The script uses the /tmp folder to indefinitely store data. This data is not held against my account limit. Of course, it may be reset at any time, but that isn’t a really big issue, as 1st, it may be re-downloaded at any time, and 2nd, /tmp is normally cleaned at reboot. Most of the time, lab machines run at least a month between reboots.

First, the script attempts to get the desired files from bart, which I am using as a site cache. If they do not exist, I grab the data from my own box, then simultaneously copy it to the cache-box, and startup Intellij. If intellij is already local, then it starts up immediately. If intellij is on the site cache, it takes about 15 seconds to copy over the network. If intellij is on my personal server, it takes a full minute and a half to do the copy.

All in all, it is pretty decent. However, can it be improved? Definitely. I improved it in 2 ways; by allowing any user to use the script, and increasing the speed. Let’s grab the original tgz from Intellij’s website. Here is the result:

#!/bin/bash

scp -r username@bart:/tmp/idea-7.0.2.tar.gz /tmp
cd /tmp

if [ -f /tmp/idea-7.0.2.tar.gz ]; then
tar -xzf idea-7.0.2.tar.gz
else
wget http://download.jetbrains.com/idea/idea-7.0.2.tar.gz
tar -xzf idea-7.0.2.tar.gz
scp -r /tmp/idea-7.0.2.tar.gz username@bart:/tmp/ &
fi

export JDK_HOME="/opt/jdk1.6.0_03"
/tmp/idea-7590/bin/idea.sh &

Now whoever runs the script doesn’t need to be me or have an ssh server running on their own box! I should note that the tgz takes about 7 seconds to transfer over the local network, or 30 seconds to 5 minutes to grab it from Intellij’s servers. Although the worst case is pretty bad, it should happen with some infrequency.

A further generalized and improved solution follows:

#!/bin/bash

REMOTE_LOCATION="http://download.jetbrains.com/idea/idea-7.0.2.tar.gz"
CACHE="username@bart:/tmp/"
COMPRESSED_FILE="idea-7.0.2.tar.gz"
COMPRESSION_CMD="tar -xzf"
RUN_ENV="export JDK_HOME=/opt/jdk1.6.0_03"
RUN_CMD="/tmp/idea-7590/bin/idea.sh"

cd /tmp

if [ ! -f $RUN_CMD ]; then
scp $CACHE$COMPRESSED_FILE /tmp
fi

if [ -f /tmp/$COMPRESSED_FILE ]; then
$COMPRESSION_CMD $COMPRESSED_FILE

else
wget $REMOTE_LOCATION
$COMPRESSION_CMD $COMPRESSED_FILE
scp /tmp/$COMPRESSED_FILE $CACHE &
fi

$RUN_ENV
$RUN_CMD &

One Comment

  1. That’s brilliant! I would never have thought to use /tmp as a flexible workaround like that. I’m definitely going to have to try this if I decide to use IntelliJ this semester.🙂


One Trackback/Pingback

  1. […] was just released, and it is definitely worth giving a spin – I’ve been a fan since I first tried it a couple of years […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: