shirts.flurdy.com
|
|
The combination of Ubuntu, IntelliJ, Maven, Jetty and JRebel enables really quick web app development in Java.
I have used Eclipse, and still do at times for certain projects at work.
I still use Netbeans at home as I just can't make my mind up.
But everyone raves about IntelliJ so I thought I'd give it a proper go this time,
and for it to be worth my time, I need Maven, Jetty and JRebel to work seamlessly.
sudo aptitude install sun-java6-jdk
In case of other Java JDK are installed, choose Sun's flavour
sudo update-alternatives --config java
sudo update-alternatives --config javac
Environment variables
sudo vi /etc/profile.d/java.sh
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export JDK_HOME=/usr/lib/jvm/java-6-sun
sudo chmod +x /etc/profile.d/java.sh
Your choice: either install via Ubuntu package repository or download the full Maven directly.
Most people would recommend downloading it directly as no unwanted garbage (Ant,gjc..) gets attached...
However I run the .deb version so this is what I will document here.
(You may try and restrict the installation of optional packages...)
sudo aptitude install maven2
Some programs depend on different environment variables for Maven.
Also the default memory assignment is very low so you may optionally add it.
sudo vi /etc/profile.d/maven.sh
export MAVEN_HOME=/usr/share/maven2
export M2_HOME=/usr/share/maven2
#export MAVEN_OPTS=-Xms128M -Xmx512M -XX:MaxPermSize=256m
#export MAVEN_OPTS=-noverify -javaagent:$JREBEL_HOME/jrebel.jar
sudo chmod +x /etc/profile.d/maven.sh
Depending on your project you may need to configure the default maven settings,
such as any mirrors you use, passwords, other repositories, profiles etc.
But that is out of scope of this document.
mkdir ~/.m2; vi ~/.m2/settings.xml
Because of maven dependency characteristics it is wise to do an initial a simple clean & build of your application do download all the dependencies.
This may take a while....
But you only have to do it once (ish..)
cd /path/to/your/project,
mvn clean;
# Wait a little while....
mvn install;
# Wait a longer while....
mvn jetty:run;
# Wait a longish while....
When ready kill Jetty with ^C (As in ctrl+c)
Remember from now on you should mostly do append -o parameter to speed up builds
You need to obtain a license to run JRebel.
I have a free Open Source one, and
are in the process of getting work to pay for one as well.
You can use the trial version for 30 days. (Its worth it)
Download the generic JAR installer
cd /tmp; unzip ~/Downloads/jrebel-*-setup.zip;
sudo -jar jrebel/jrebel-setup.zip
I tend to choose /opt/ZeroTurnaround/JRebel as my install path, but the default it /usr/local/ZeroTurnaround/Jrebel.
If the installer doesn't trigger the configuration, or you want to reconfigure:
sudo /opt/ZeroTurnaround/JRebel/bin/jrebel-config.sh
sudo vi /etc/profile.d/maven.sh
And then uncomment or add the MAVEN_OPTS line:
export MAVEN_OPTS="-noverify -javaagent:/opt/ZeroTurnaround/JRebel/jrebel.jar $MAVEN_OPTS"
sudo mkdir /var/log/jrebel;
sudo chown jrebel:jrebel /var/log/jrebel
sudo vi /etc/profile.d/jrebel.sh
export JREBEL_HOME=/opt/ZeroTurnaround/JRebel
sudo chmod +x /etc/profile.d/jrebel.sh
Decide which version you want. I will assume a trial of the ultimate edition.
Select your IntelliJ download such as this one.
cd /tmp;
tar xzf ~/Downloads/ideaIU-9.0.2.tar.gz;
sudo chown -R root:root idea-IU-95.96;
sudo mv idea-IU-95.96 /opt/;
On first launch IntelliJ will ask you a series of questions regarding plugins etc.
Choose maven plugin amongst others.
Open settings via File/Settings/maven and enter Maven home directory as /usr/share/maven2
IntelliJ does not support Compile-on-save / Auto-build.
This feature is essential to get the best time saving from using JRebel.
So you will have to manually enter ctrl++shift+F9 to compile your file, or just ctrl+F9 to build your whole project.
A decent work around is to map ctrl+s as the build command.
Another is to install a plugin called Eclipse Mode, which auto build like eclipse.
(I have not been able to get this to work as expected)