Integrating Cygwin, MiKTeX, Java Maven and IntelliJ IDEA in Windows

12 Jun 2015

I get a new Windows laptop. I plan to give Windows a try. The pain of using windows is it is often not easy to get different application highly integrated by default. This is how I set up the most important developing environment I use.

Cygwin

The first installation is given to Cygwin, a Linux-like environment for Windows. The installation is very easy. I installed some most used software, such as vim and git, in the setup process. Then, I installed apt-cyg, a apt-get like Cygwin package manager:

lynx -source rawgit.com/transcode-open/apt-cyg/master/apt-cyg > apt-cyg
install apt-cyg /bin

You can use this to install make:

apt-cyg install make

MiKTeX

MiKTeX is a Windows only latex software. Compared to TexLive, MiKTeX can install packages on the fly. It is suggested to use MikTeX in Windows. You can also install texlive in Cygwin:

apt-cyg install texlive

But for me, the cygwin still calls MiKTeX without any problem to compile my Latex Example by using Makefile.

Java Maven

Using Java in Cygwin is easy. Just download the latest Java SE Development Kit, and every thing works fine. But for the Maven, you can not get it from apt-cyg install maven. Download maven and extract it to C:\apache-maven-3.3.3\bin. And then add C:\apache-maven-3.3.3\bin to PATH in system environment.

You also need to add JAVA_HOME variable with value C:\Program Files\Java\jdk1.8.0_45 in system environment (Note: use jdk rather than jre).

Then, you can run mvn and java with in Cygwin.

IntelliJ IDEA

Again, the installation of IntelliJ IDEA is easy. There are some version to configure default terminal to cygwin.

The first is set path in Setting -> Tools -> Terminal to:

C:\cygwin64\bin\bash.exe

But you can not use ls like command. To solve this, you can use path:

C:\cygwin64\bin\bash.exe --login -i

But the default directory changed to ~. The solution is use a bat script C:\cygwin64\Cygwin.local.bat:

@echo off

set CHERE_INVOKING=1
C:\cygwin64\bin\bash --login -i

You may need to add export TERM=cygwin to ~/.bash_profile to avoid the problem regarding to the long commands.

Because of the integration issue, it is recommended to disable version control in idea and use Github for Windows instead.

All done.