I'm looking for Linux distribution only with command line and I need in it only g++, javac, python. I found Damn Small Linux but it doesn't have g++ and javac. It should have it out of the box because Linux will be installed by a script in virtual machine (qemu KVM). An easy way to prepare my Linux would be as much appreciated as Linux itself. The distribution should be as small as possible.
I would use whatever distro you are most familiar with administering (preferably what is on the host system to make tooling easy). You don't need a completely separate distro to do this, all you need is a package set and install script to install your current / preferred distro to a target file system (in a loopback file to create a drive image). This will get you exactly the set of tools you need and no more with little fuss and a lower learning curve than automating the install of some other distro.
If you state the distro of choice and ask a specific question I'm sure somebody here can be helpful with the details.
Have a look at ArchivistaVM, it is only about 100 MByte (with Xorg + Firefox), or 72 MByte without GUI:
Zip-File without GUI (same password) https://www.archivista.ch/avtest5.zip
It works completely in RAM, startup time is about 15 or 20 seconds, there is a cluster mode (drdb), but at this time, the documentation is not yet fully available in English.
Fedora with the AOS kickstart. g++ and javac/gcj can be installed via yum after, or you can modify the kickstart file to include them in the install.
Distros like Archlinux, Gentoo or Slackware would get you where you want, but you'll probably need to get your hands dirty a bit.