Xubuntu 창 크기 조절하기


Xubuntu에서 창 크기 줄이고 늘리는 게 영 불편했다. 보통 오른쪽 아랫부분에 마우스를 가져가면 할 수 있을 거라고 생각했지만 위/아래 혹은 왼/오른쪽이 아닌 대각으로 잡히는 부분이 너무 작았다. 뭔가 설정파일을 수정하면 될 듯 해서 찾던 중 그냥 Alt 키를 누르고 마우스 오른쪽 버튼으로 대충 잡아끌면 되는 듯 하다.

Ask Ubuntu.

Changing Ubuntu Server Apt Source Repository


References

Abstract

Ubuntu Server, unlike the Ubuntu Desktop, has no GUI environment with fresh installation.

Backup

$ pwd
/etc/apt
$ ls -l
...
sources.list
...
$ sudo cp sources.list sources.list.bak
$ ls -l
...
source.list
source.list.bak
...
$ 

Check

Let’s take a look at the file.

$ pwd
/etc/apt
$ cat source.list
...
deb-src http://slower.ubuntu.com/ubuntu/ trusty multiverse
...
$

Update

Change all slower.ubuntu.com to faster.ubuntu.com.

$ pwd
/etc/apt
$ sudo vi source.list
$ cat source.list
...
deb-src http://faster.ubuntu.com/ubuntu/ trusty multiverse
...
$ 

Note

that those domain addresses used in above example aren’t real. In my case I changed kr.archive.ubuntu.com to ftp.daum.net.

Installing VirtualBox Guest Additions in Ubuntu Server


Insert the image by selecting the menu item of Devices / Insert Guest Additions CD Image... (Host+D).

Mount the inserted image.

$ sudo mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom

Execute VBoxLinuxAdditions.run file.

$ cd /mnt/cdrom
$ ls -1F
...
VBoxLinuxAdditions.run
...
$ sudo ./VBoxLinuxAdditions.run
...
$

The script may complain about the absence of gcc and make. Install them and run the script again.

$ sudo apt-get -y install gcc make
...
$ sudo ./VBoxLinuxAdditions.sh
...
$

You can unmount the cdrom.

$ sudo umount /media/cdrom
$

You might want to reboot the guest.

$ sudo /sbin/shutdown -r now
$

One of benefits that guest additions offers is sharing folders between the host and the guest.

$ ls -l /media
drwxr-xr-x 2 root root    ____ MMM dd HH:mm cdrom/
drwxrwx--- 1 root vboxsf _____ MMM dd HH:mm sf_shared/
$

You can add yourself to vboxsf group and use them.

$ sudo adduser <yourself> vboxsf
...

You need to logout and login for making the change effects.

$ logout
$

Now you can read/(write) in the shared directory.

$ cd /media/sf_shared/
$ echo test > test.txt
$ cat test.txt
test
$

Installing Apache Maven in Ubuntu


Installing the latest binary

Copy the link of the latest binary at here.

$ cd /opt
$ sudo wget http://.../.../.../apache-maven-x.y.z-bin.tar.gz
$ ls -1F
apache-maven-x.y.z-bin.tar.gz
$ sudo tar -xzf apache-maven-x.y.z-bin.tar.gz
$ ls -1F
apache-maven-x.y.z/
apache-maven-x.y.z-bin.tar.gz
$ sudo ln -s apache-maven-x.y.z apache-maven-latest
$ ls -1F
apache-maven-x.y.z
apache-maven-x.y.z-bin.tar.gz
apache-mavenlatest@
$

Edit /etc/environment and append :/opt/apache-maven-latest/bin to PATH. Note that : character is a path separator.

$ cat /etc/environment
PATH="/../..:/opt/apache-maven-latest/bin"
$ source /etc/environment
$ which mvn
/opt/apache-maven-latest/bin/mvn
$ mvn --version
Apache Maven x.y.z ...
Maven home: /opt/apache-maven-latest
...

Upgrading to a newer version

When you need to upgrade to a newer version. Just extract the newer binary and change the symbolic link's target with the -f option.

$ cd /opt
$ sudo wget http://.../.../.../apache-maven-9.9.9-bin.tar.gz
$ ls -1F
apache-maven-9.9.9-bin.tar.gz
$ sudo tar -xzf apache-maven-9.9.9-bin.tar.gz
$ ls -1F
apache-maven-9.9.9/
apache-maven-9.9.9.-bin.tar.gz
$ sudo ln -sf apache-maven-9.9.9 apache-maven-latest
$

Executable Jar with Apache Maven


Apache Maven을 이용하여 실행 가능한 jar파일을 만들어 보자구!!!

References

GitHub

$ git clone git@github.com:jinahya/executable-jar-with-maven.git
...
$ cd executable-jar-with-maven/
$ mvn clean package
...
$ ls -l target/
...

Exec Maven Plugin

FYI, Apache Maven을 이용하여 직접 main(String[]) 메서드를 실행할 수 있다.

$ mvn -quiet exec:java -Dexec:main=com.github.jinahya.Main
hello, world
$

Maven Jar Plugin

우선 Maven Dependency Plugin을 사용하여 실행에 필요한 dependency들을 target/${project.build.finalName}.lib/에 복사한다.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.8</version>
  <executions>
    <execution>
      <id>copy-dependencies</id>
      <phase>package</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/${project.build.finalName}.lib</outputDirectory>
      </configuration>
    </execution>
  </executions>
</plugin>

그리고 Maven Jar Plugin을 다음과 같이 설정하여 위에서 내려받은 라이브러리들의 위치를 META-INF/MANIFEST.MFClass-Path항목에 추가한다.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>2.4</version>
  <configuration>
    <archive>
      <manifest>
        <addClasspath>true</addClasspath>
        <classpathPrefix>${project.build.finalName}.lib/</classpathPrefix>
        <mainClass>com.github.jinahya.Main</mainClass>
      </manifest>
    </archive>
  </configuration>
</plugin>
$ pwd
/.../path/to/.../executable-jar-with-maven/
$ mvn clean package
...
$ ls -1F target/
...
executable-jar-with-maven-1.0-SNAPSHOT.jar
executable-jar-with-maven-1.0-SNAPSHOT.lib/
...
$ unzip -p target/executable-jar-with-maven-1.0-SNAPSHOT.jar META-INF/MANIFEST.MF
...
Class-Path: executable-jar-with-maven-1.0-SNAPSHOT.lib/guice-4.0-beta4
 .jar executable-jar-with-maven-1.0-SNAPSHOT.lib/javax.inject-1.jar ex
 ecutable-jar-with-maven-1.0-SNAPSHOT.lib/aopalliance-1.0.jar executab
 le-jar-with-maven-1.0-SNAPSHOT.lib/guava-16.0.1.jar
...
Main-Class: com.github.jinahya.Main

$ ls -1F target/executable-jar-with-maven-0.1-SNAPSHOT.lib/
aopalliance-1.0.jar
guava-16.0.1.jar
guice-4.0-beta4.jar
javax.inject-1.jar
$ java -jar target/executable-jar-with-maven-0.1-SNAPSHOT.jar
hello, world
$ 

Maven Assembly Plugin

Maven Assembly Pluginjar-with-dependencies descriptor를 사용하여 필요한 클래스들을 모두 포함하는 아카이브를 만들 수 있다.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-assembly-plugin</artifactId>
  <version>2.4</version>
  <configuration>
    <archive>
      <manifest>
        <mainClass>com.github.jinahya.Main</mainClass>
      </manifest>
    </archive>
    <descriptorRefs>
      <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
  </configuration>
</plugin>
$ pwd
/.../path/to/.../executable-jar-with-maven/
$ mvn clean package
...
$ ls -1F target/
...
executable-jar-with-maven-1.0-SNAPSHOT-jar-with-dependencies.jar
...
$ java -jar target/executable-jar-with-maven-1.0-SNAPSHOT-jar-with-dependencies.jar 
hello, world

Maven Shade Plugin

다음은 Maven Shade Plugin을 이용하는 방법이다.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>2.3</version>
  <configuration>
    <shadedArtifactAttached>true</shadedArtifactAttached>
    <transformers>
      <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
        <mainClass>com.github.jinahya.Main</mainClass>
      </transformer>
    </transformers>
  </configuration>
  <executions>
    <execution>
      <id>shade</id>
      <!--phase>package</phase--> <!-- default -->
      <goals>
        <goal>shade</goal>
      </goals>
    </execution>
  </executions>
</plugin>
$ pwd
/.../path/to/.../executable-jar-with-maven/
$ mvn clean package
...
$ ls -1F target/
...
executable-jar-with-maven-1.0-SNAPSHOT-shaded.jar
...
$ java -jar target/executable-jar-with-maven-1.0-SNAPSHOT-shaded.jar
hello, world
$

OneJar Maven Plugin

다음은 onejar-maven-plugin을 사용하는 방법이다.

<plugin>
  <!--groupId>org.dstovall</groupId--> <!-- not available on the central -->
  <groupId>com.jolira</groupId>
  <artifactId>onejar-maven-plugin</artifactId>
  <version>1.4.4</version>
  <executions>
    <execution>
      <configuration>
        <mainClass>com.github.jinahya.Main</mainClass>
        <attachToBuild>true</attachToBuild>
        <!-- https://code.google.com/p/onejar-maven-plugin/issues/detail?id=8 -->
        <!--classifier>onejar</classifier-->
        <filename>${project.build.finalName}-onejar.${project.packaging}</filename>
      </configuration>
      <goals>
        <goal>one-jar</goal>
      </goals>
    </execution>
  </executions>
</plugin>
$ pwd
/.../path/to/.../executable-jar-with-maven/
$ mvn clean package
...
$ ls -1F target/
...
executable-jar-with-maven-1.0-SNAPSHOT-onejar.jar
...
$ java -jar target/executable-jar-with-maven-1.0-SNAPSHOT-onejar.jar
[... Some nasty warnings here ...]
hello, world
$