This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Java/ko

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This page is a translated version of the page Java and the translation is 42% complete.
Outdated translations are marked like this.
Resources

Java is a programming language, originally developed by Sun Microsystems, which uses a runtime to allow running Java-developed applications on various platforms. It is a popular choice for developers who want to create cross-platform applications.

자바란 무엇인가요?

간단히 살펴보기

자바는 썬 마이크로시스템즈의 엔지니어가 개발한 프로그래밍 언어입니다. 언어는 객체지향이며 각각의 플랫폼에서 코드를 다시 컴파일하지 않아도 여러 플랫폼에서 동작하도록 설계했습니다. 비록 자바를 네이티브 프로그램처럼 컴파일 할 수 있지만 대부분의 자바 배포 프로그램은, 가비지 콜렉션과 같은 기능을 붙여가며 이식성을 부여할 수 있습니다. 플랫폼은 독립적으로 자바 컴파일러가 운영체제가 아닌 JRE(자바 런타임 환경)에서 실행할 "자바 바이트 코드"라고 하는 중간 형태의 자바 코드로 컴파일 할 수 있습니다.

자바 바이트 코드를 실행하려면 JRE(자바 런타임 환경)을 설치해야합니다. JRE는 핵심 라이브러리, 플랫폼과 별개로 동작하는 자바 가상 머신, 브라우저 플러그인, 등을 제공합니다. JDK(자바 개발 키트)는 바이트 코드 컴파일러 및 디버거와 같은 프로그래밍 도구를 추가합니다.

Installing a virtual machine

선택

Gentoo provides numerous Java Runtime Environments (JREs) and Java Development Kits (JDKs). The current choices include:

Vendor JDK JRE
The IcedTea Open Java SE (formerly icedtea6-bin) dev-java/icedtea and dev-java/icedtea-bin
Oracle's Java dev-java/oracle-jdk-bin dev-java/oracle-jre-bin
The GCJ IcedTea GNU GCC Java (currently IcedTea-7) dev-java/icedtea sys-devel/gcc USE="gcj"

Installing a JRE/JDK

To install the profile's default JDK run:

root #emerge --ask virtual/jdk

To install the profile's default JRE run:

root #emerge --ask virtual/jre

Some JDKs and JREs, including the Oracle packages, require accepting an End User License Agreement, or EULA. If its license (such as dlj-1.1) is not listed in the ACCEPT_LICENSE variable (found in /etc/portage/make.conf), then the JDK/JRE will be unable to be installed. For more information on how to add acceptable licenses to make.conf read the Licenses chapter of the Portage Handbook.

제한 라이선스의 번거로움을 피하려면 OpenJDK 프로젝트의 공개 Java 구현체인 icedtea-bin 설치를 고려하십시오.

참고
JDK에는 "JRE가 들어있음을 인지하십시오. JDK를 이머지하면 JRE 설치는 필요 없습니다.

Installing IcedTea GCJ Virtual Machine

중요
gcj is deprecated and is removed in GCC versions 7.0 and greater. It is unavailable from GCC 6.0 on Gentoo. Consider this section deprecated.

The IcedTea virtual machine is provided in source code and requires compilation by a Java bytecode compiler. This bootstrapping can be executed by the GNU Compiler for Java (GCJ). This compiler is available when GCC is built with the gcj USE flag.

When GCC is rebuilt with this USE flag set, the dev-java/icedtea package can be installed. Because of a Portage bug, users need to install dev-java/gcj-jdk and dev-java/ant-core explicitly first if they are not already present.

root #emerge --ask --oneshot dev-java/gcj-jdk dev-java/ant-core
root #emerge --ask dev-java/icedtea:7

가져오기에 제한이 있는 가상 머신 설치

일부 JDK와 JRE를 설정하려면 추가 설정 몇단계를 거쳐야합니다. 꾸러미를 이머지하는건 보통입니다. 추가 과정이 필요하다면 이빌드는 사용자에게 어디서 무얼 다운로드해야 할 지 지침을 제공합니다.

Download the indicated file(s) into /usr/portage/distfiles Once the files are in the right directories, rerun the emerge command, at which point the JRE/JDK will be begin to install.

헤드리스 JRE 설정

Sometimes there is no need for a full JRE with all the capabilities of java. Using java on a server often does not require any GUI, graphical, sound or even printer related features. To install a simplified (sometimes also referred to as headless) JRE, a few USE flags need to be changed for the selected JRE flavor.

파일 /etc/portage/package.useRequired USE flag changes
dev-java/icedtea headless-awt -alsa -cups
dev-java/icedtea-bin headless-awt -alsa -cups
dev-java/oracle-jre-bin headless-awt -alsa -cups

Depending on the current Gentoo profile, this might already be the case. As usual, the USE flag settings that are applicable to a particular package can be checked by running emerge in pretend mode:

user $emerge --pretend --verbose virtual/jre

자바 가상 머신 설정

간단히 살펴보기

젠투는 여러 JDK와 JRE를 어떤 기능상 중복 없이 설치할 수 있습니다.

Using the java-config tool with root privileges, a system-wide default java virtual machine (VM) can be set. Users can also use java-config to custom set their personal VM on a user-by-user basis.

참고
eselect can also be used to change the system and user VM. See eselect java-vm help.

기본 가상 머신 설정

Running the java-config command with the --list-available-vms option will output a list of all JREs and JDKs installed on the system. Here is an example of the output:

root #java-config --list-available-vms
The following VMs are available for generation-2:
1)      IcedTea JDK 7.2.6.3 [icedtea-7]
*)      IcedTea JDK 3.0.1 [icedtea-8]
참고
'빌드 전용'으로 표기한 가상머신은 보안 취약점을 안고 있거나 끝물에 다다른(End Of Life)상태일 수도 있습니다. 젠투에서는 이 가상머신을 시스템 또는 사용자의 가상 머신으로 설정하지 않길 권합니다. 자세한 내용은 빌드 전용 가상머신편을 참고하십시오.

The * indicates this is the current active JVM (system-vm or user-vm when set). The name in the brackets ([]) is the handle or ID for that particular VM. The handle or the number to java-config --set-system-vm can be used to set the VM. The following text provides an example of how to set the system VM.

(원하는대로)직접 system VM을 설정하려면:

root #java-config --set-system-vm icedtea-7
Now using icedtea-7 as your generation-2 system JVM

대안책: 관리 번호로 가상 머신 선택:

root #java-config --set-system-vm 3
Now using icedtea-7 as your generation-2 system JVM

일반 사용자는 java-config --set-user-vm 명령을 활용하십시오.

참고
source-ing the profile for existing shell sessions is not usually needed when changing the user or system VM. The only exception is that variables such as JAVA_HOME will still point to the old location after setting a user VM for the first time or revert back to the system VM.

Build only VM

일부 가상머신은 끝물에 다다른 상태이거나 보안 취약성이 있어 빌드 전용으로 플래그 표시했습니다. 이 가상머신은 젠투 실행 관리자를 통해 프로그램 실행을 목적으로 자동으로 활용하지 않지만(run-java-tool 스크립트는 가상머신을 전환하는 도구로 설계했습니다), 젠투 빌드 환경에서 어떤 꾸러미 빌드에 필요할 때 여전히 사용할 수 있게 했습니다. 이들 가상 머신 설정은 시스템 가상머신으로든 사용자 가상머신으로든 젠투 실행 관리 스크립트에서 사용하지 않는 것처럼 /usr/bin/{java,javac,..} 실행 파일을 구동할 때 실행할 가상머신으로 사용하지 말길 바랍니다.

기본 CLASSPATH 값 설정

경고
The options explained in this section should be considered deprecated and will most likely be removed in the future. It is strongly recommended against using these, because Java projects or applications should ideally manage their own classpaths. When choosing to specify a default CLASSPATH, some applications may behave unexpectedly, because classes they were not expecting to be on the classpath.

java-config can also be used to set a system-wide default CLASSPATH, as well a user-specific default CLASSPATH.

First, list available Java libraries installed on the system to possibly put in the CLASSPATH variable. Here is an example of output:

root #java-config --list-available-packages
[xerces-2] The next generation of high performance, fully compliant XML parsers in the Apache Xerces family (/usr/share/xerces-2/package.env)
[junit] Simple framework to write repeatable tests (/usr/share/junit/package.env)
[bsh] BeanShell: A small embeddable Java source interpreter (/usr/share/bsh/package.env)
[bcel] The Byte Code Engineering Library: analyze, create, manipulate Java class files (/usr/share/bcel/package.env)
[log4j] A low-overhead robust logging package for Java (/usr/share/log4j/package.env)
...

Again, the names in brackets ([]) are the IDs to pass to java-config --set-system-classpath. Here is an example:


root #java-config --set-system-classpath log4j,xerces-2
참고
현재 디렉터리 (.)는 시스템 로그인 프로파일로 추가할 수 없으므로 시스템 클래스 경로의 일부가 아닙니다.

Update the environment by logging out, then in again or by typing source /etc/profile.

사용자별 설정시 java-config --set-user -classpath 명령으로 ~/.gentoo/java-env-classpath를 만들고 쉘 프로파일로 source 명령을 처리합니다.

코드 지정 클래스경로 가져오기
if [[ -f "${HOME}/.gentoo/java-env-classpath" ]]; then
       source ${HOME}/.gentoo/java-env-classpath
fi

시스템 전체 또는 사용자별 기본 클래스 경로에서 다음과 같이 쉘 프로파일에 추가하려 할 때를 가정해보겠습니다. 다음 처럼 해보십시오:

root #export CLASSPATH="${CLASSPATH}:$(java-config --classpath log4j,xerces-2)"

Java browser plugins

The Java browser plugin used to be managed via eselect java-nsplugin. This has now been removed in favor of a simpler out-of-the-box experience. For basic usage, simply emerge the chosen JVM with the nsplugin USE flag enabled. Note that Oracle's plugin is only available for amd64 and x86.

Also note that Chromium-based browsers no longer support NPAPI-based plugins since the code was removed in September 2015. The list of supporting browsers is shrinking but still includes Firefox as of version 46.

For more information, including JVM selection, Web Start, and multilib, see the README installed with icedtea-web.

Java에서 사용할 USE 플래그

USE 플래그 설정

For more information regarding USE flags, refer to the USE flags chapter from the Gentoo Handbook.

USE flags

  • The java flag adds support for Java in a variety of programs;
  • The nsplugin flag adds support for Mozilla-like browsers (including Firefox). This is needed for viewing Java applets in a Mozilla-like browser;
  • The jce flag adds support for the Java Cryptography Engine;

Following USE flags go in JAVA_PKG_IUSE.

  • The source flag installs a zip of the source code of a package. This is traditionally used for IDEs to 'attach' source to the libraries that are being use;
  • For Java packages, the doc flag will build API documentation using javadoc.

추가 참조

외부 자료

More information can be found offline:

  • man java-config
  • java-config --help

이 문서와 관련한 제안이나 질문이 있으면 젠투 Java 팀의 java@gentoo.org 전자메일 주소로 문의바랍니다.


This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Joshua Nichols, Karl Trygve Kalleberg, Joshua Saddler (nightmorph)
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.