JA:Java Runtime Environment

From OpenStreetMap Wiki
Jump to navigation Jump to search

broom

Help (89606) - The Noun Project.svg

Java mascot “Duke”

Java 実行環境は Java プラットフォームの一部です。 Java プラットフォームはオラクル社の一連のソフトウェア製品群を示します。プラットフォームは Java プログラムの開発や実行に使用されます。プラットフォームには(Java 仮想マシンと呼ばれる)実行エンジンを含んでおり、同じ Java のプログラムファイルを異なるオペレーティングシステムで実行することができます。これは大きな利点です。

一方、 Java アプリケーションは「Java 実行環境」(JRE)を必要とし、そのインストール媒体は実行するオペレーティングシステムに依存します。ここでは、 Java をどうやってあなたのPCにインストールするか、どうやって JRE を通して Java のアプリケーションを実行するかを説明します。

Java 実行環境に関する Wikipedia の説明も参照してください。

OSM の多くのソフトウェアは Java 動作環境(Java Runtime Environment 略して JRE)に依存しています。

インストール方法

もし、ウェブブラウザ内でアプレットを実行することに興味がない場合は、 install any browser plugins/extensions選択しないかもしれません。これは Java のデスクトッププログラムを実行するのに必要ではなく、しかも、しばしばセキュリティリスクにさらされます。後で disable the browser プラグインを使うこともでき、ブラウザを無効にしたり有効にしたりするのにも使えます。

Windows

  1. java.com からインストーラーをダウンロードしてください
  2. 実行してください(必要な場合は、リンク先のダウンロードページの説明を参照してください)。
    • The default options are generally okay (installs to "Program Files/Java") except …
      • It is a good idea to not install any additional advertised crap software (search bars, security checkers, …) – uncheck this during the install procedure.
      • It is also a good idea to not install the browser plugin or disable "web content" afterwards in the Java settings (see above for more info).
      • Maybe you would also want to disable the 'java update checker' since this will add a new auto start-up item (one of those things which slows down start-up times very slightly). However, then you need to manually check for new Java versions (important if you use the browser plugin/extension).
      • Good news: At least the current 64 bit offline installer (only this was tested) for Oracle's Java 8 seems to not contain crap software. Also it seems not to enable "web content" (browser plugin) by default.

Mac OS X

Java 7 and later is not provided by Apple. You can download Java from Oracle:

  1. Download the installer from java.com.
  2. Install from the dmg file as usual. For more info see the links there to Oracle's "install guide" or "system requirements" for Java on Mac OS.
  3. Note that the JRE download (as opposed to the JDK download) from Oracle does not replace the shortcuts like "java" in your command line Terminal (see [1]). To access the JRE from the command line use /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java. Some application launchers, e.g. JOSM, still work with the JRE.

Linux

  • Use your distribution's package installer/manager to install a Java VM (JRE). This will automatically keep the Java version updated. Often the JRE from OpenJDK, the free software version of Oracle's implementation, is available in the default repositories. Some distribution-specific instructions follow.
  • Alternatively, install Oracle's Java from Java.com. Multilingual install help available (e.g. German, Japanese, Russian).

Arch Linux

Debian

  • (ルート権限で)次のコマンドを実行してください:
    $ apt-get install sun-java6-jre
  • Debian Lenny には、JOSM が (いくつかのjosmプラグインのオプションつきで)リポジトリーにはいってます。:
    $ sudo aptitude install josm josm-plugins

注: もし他の JVM を導入していて、SUN の Java 仮想マシンを使いたい場合には、josm を開始するときに、次のようにしてください。

JAVACMD=/usr/lib/jvm/java-6-sun/bin/java josm

Gentoo

See "Installing a JRE/JDKs" section at gentoo wiki.

Or see the following older info. "Older" because since "sun" likely the wrong package name as this is the old Java producer.

broom

この記事または節には失効した情報が含まれている可能性があります。情報がもう正しくないか、妥当ではない状態になっています。
最新の事情をご存知の方は、この情報を更新して誰もがわかるようにしてください。 (Discussion)

Standard installation with Portage:

emerge -av sun-jre-bin

Gentoo ebuild コレクションには、OSMの Java アプリケーションが既にあります。これのうちどれかをインストールすると、JREが依存関係でインストールされます。例えば:

emerge -av josm

JOSM プラグインなどもebuildsで入手可能です。 http://svn.openstreetmap.org/applications/utils/gentoo/ に完全なリストがあります。最新の開発バージョンのJava アプリケーションや、プラグインが見たければ、OpenStreetMap Gentoo オーバーレイを利用してください。

openSUSE/Fedora/Mandriva

See the "Installing Java" article at the openSUSE Support Database.

Ubuntu

See for example …

FreeBSD

See the guide at freebsd.org.

Javaアプリケーションの実行方法

多くの Java アプリケーションは、拡張子が".jar"のファイルにパッケージ化されています。

jarをダブルクリックする

Many jar files are "runnable". This means you can simply double-click the file on many operating systems. The file contains details of which Java class files to run by default, and the application just starts up. Easy!

This assumes a few things though. Firstly you'll need Java installed as detailed above, and with the necessary operating system hooks enabled, and these may not be available for some operating systems.

This is also an security issue. Think twice before you set up your system to start jar files automatically by just clicking – this would work with all downloaded jar files then (also with accidental, malicious downloads)! Better use the command line or a manually built link/script.

コマンドターミナルで実行する

これは一番基本で、どのオペレーティングシステムでも使える方法です。いくつかのJava アプリーケーションは(例えばmkgmap.jar)はターミナルなしには実行できません。

たとえ、コマンドラインの経験がなくてもそんなに難しくはありません。例えば、JOSM を起動するには、次のようなコマンドを入力してください:

cd [josm.jarを入れたディレクトリーのパス名]
java -jar josm.jar

そうすれば、JOSM が動きます。

コマンドターミナルってどこ?

  • Windows:
    • "スタート"ボタンをクリックしてください。"コマンドプロンプト"が、"プログラム/アクセサリー"の中に見つかるでしょう。もしみつからなければ、あなたのシステムはコマンドプロンプトのショートカットがインストールされてません。しかし、インストールする必要もありません。
    • "スタート"メニューの"名前を指定して実行"をクリックして、出てきたウィンドウのボックスに"cmd"と入力してください。
    • Alternatively create a file 'run-josm.bat', and edit it in notepad. Enter your command as the only contents of the file. Save it, then double-click the file to run it. If the black command window disappears immediately, you can debug by adding a new line 'PAUSE' in the bat file.
  • Mac OS X: まず、ファインダーから"アプリケーション"、そして"ユーティリティー"にいきます。"ターミナル"が見つかるはずです。

Windows

通常 JRE インストーラーが、.jar ファイルタイプを javaw.exe (これはもう一つのJava 実行コマンドで、Windows用に特別にあるターミナルを必要としないGUIアプリケーションを実行するためのものです。) で実行する様に関連付けるので、.jar ファイルをダブルクリックするだけで実行できます。 しかし、これではオプションが付けられません。オプションを足す方法は2つあります。

  • .bat ファイルを作成します。
    1. テキストエディタ(例:メモ帳)を起動し、新しいテキストファイルを作成します。
    2. テキストファイルにコマンドを記載します。"java"コマンドを実行する前に、"cd"コマンドを記載して、起動ディレクトリを指定したほうがよいでしょう。
    3. 拡張子を .batに変更して保存します。(例: josm.bat)
    • .batファイルをダブルクリックするとコマンドプロンプトが起動し、.batファイル内に記載されているコマンドが自動的に実行されます。
  • ショートカットを作る (.lnk ファイル)
    1. Right-click on a .jar file. Click "Create Shortcut" on the pop-up menu. (You can use "Send to/Desktop (create shortcut)", too.)
    2. Right-click the created shortcut and select properties.
    3. The full path of .jar file is shown on Target box. Add "javaw [Options for JavaVM] -jar " before the .jar path. Add " [Options for the application]" after the path.
    4. If you need to specify the current directory when it runs, you can write it in "start in" box.
    • When you double-click the shortcut, it runs the application with the options.
    • The shortcut is free to move, to rename and to change the icon. I recommend it to rename it to the application name (eg. "JOSM" without "shortcut to"), and to move it to under the "start menu".

Mac OS X

Mac OS 10.4 以上が必要です。10.3では、できません。10.4.xと10.5.xでは、単にjar ファイルをダブルクリックすると、Java 1.5が、.jarファイルを実行します。 もっとメモリーを確保したい場合、(大きなファイルを編集するとか、'変なことが起こる'メモリーエラーになったとかで)

  1. ターミナルを開きます。
  2. josm-latest.jar が保存されているディレクトリーに移動します。デスクトップなら、'cd Desktop'としてみてください。
  3. 次のラインをコピーアンドペーストでターミナルに入力し、JOSMを512メガバイトのメモリー確保でスタートさせます。:
  4. Copy and paste the following line in to the terminal to start JOSM with more memory:
java -Xmx512M -jar josm-latest.jar

Include -Dapple.laf.useScreenMenuBar=true to place the menu on the OS X menu bar, and -Xdock:name="JOSM" -Xdock:icon="logo.png" to give it icon and name.

If you're not familiar with scripts just use the Jar Bundler application, coming with MacOS X. It'll create a start application, let's call it "JOSM!". You'll find it here /Developer/Applications/Java Tools/ or here /Developer/Applications/Utilities/. Just double click to launch it. In the first menu build information enter the location of the just downloaded JOSM jar file by clicking the choose... button. In the third menu properties choose the edit box vm options to enter the appropriate memory settings. If you're able to afford it try spending up to a GB RAM to JOSM. Here's what to enter into the edit box: -Xmx512M -XX:MaxPermSize=512M (which starts the JOSM application with 512MB and grants up to 1GB of RAM). Then press create application... to create the start application (call it JOSM!, f.e.). JOSM! does not have to be in the same directory as the jar file. Just save or move JOSM! to your applications folder. Double click JOSM! to start the JOSM aplication.

Via shell scripts (Linux, FreeBSD, Mac OS X)

Input a command line as the above is the basic. Usually the command line become long. It is better to make a shell script to run for each jars. There are some users make some useful shell scripts for specific applications; for example see JOSM/Linux#Start JOSM.

Options for application execution

You can add options on the command line, in the command of your shortcut, in your script or – depending on your system – in an environment variable (_JAVA_OPTIONS). There are two kinds of options: One kind for initialising the Java Virtual Machine, the other for application options.

java [Options for JavaVM] -jar application.jar [Options for the application]

The following are commonly used options for the Java VM:

メモリオプション
  • -Xmx is the only memory option which really matters. これは、Javaアプリケーションの最大メモリ容量を指定します。初期値は64 MBで小さすぎます。これを、例えば 512 MB に増やすには、"-Xmx512m"とします。(other Java memory options)
プロキシオプション
  • -Dhttp.proxyHost= は、http をプロキシを通して使いたいときに、これでプロキシサーバーを指定します。例えば、"-Dhttp.proxyHost=192.168.1.1" とします。
  • -Dhttp.proxyPort= これでプロキシポート番号を指定します。初期値は 80 です。例えば、"-Dhttp.proxyHost=8080" とします。
  • -Dhttp.proxyUser= プロキシユーザー名を指定します。プロキシサーバーに認証が必要な場合に設定します。
  • -Dhttp.proxyPassword= プロキシパスワードを指定します。プロキシサーバーに認証が必要な場合に設定します。
  • -Djava.net.preferIPv6Addresses=true IPv6が必要な時に、これを指定します。ところで、まだOpenStreetMapのサーバーはIpv6をサポートしていません。
グラフィックアクセラレータ
  • -Dsun.java2d.opengl=true OpenGLを有効化します。 あなたのPCがOpenGL 2Dグラフィックアクセレータをサポートしているときに指定してください。この設定に問題がある場合には、(WinXP + nVidia FX1500 + dual monitorでは、アイコンバックグラウンド・ダイアログがおかしくなります。) 代わりに -Dsun.java2d.opengl=true -Dsun.java2d.opengl.fbobject=falseを設定してください。またOpenGLオプションは、Linux上のウィンドウマネージャーに問題を起こすことが知られています。
  • -Dsun.java2d.d3d=true -Dsun.java2d.ddscale=true Windowsでの、 DirectX グラフィックアクセレーションを有効にします。
nicer graphics
  • -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true switches anti-aliasing (smoother edges on text) on

The options for the application depend on each applications. See their page for these.