Java開発環境構築手順

この記事は古いです。d:id:u6k:20090616を参照してください。


http://d.hatena.ne.jp/u6k/20090418

個人的なJava開発環境の構築手順を記述します。普段はこれをzipアーカイブして持ち歩き、Java開発環境を構築するときはそれを解凍することで楽に構築できるようにしています。


Apache Ant

ダウンロード、展開、

Apache Ant」をダウンロード、「C:\eclipse」フォルダに展開します。「C:\eclipse\apache-ant-x.x.x」フォルダが作成されます。


Apache Maven

ダウンロード、展開

Apache Maven」をダウンロード、「C:\eclipse」フォルダに展開します。「C:\eclipse\apache-maven-x.x.x」フォルダが作成されます。


XAMPP for Windows

ダウンロード、展開

XAMPP for Windows」をダウンロード、「C:\eclipse」フォルダに展開します。「C:\eclipse\xampp」フォルダが作成されます。


setup-xampp.bat

「%XAMPP_HOME%\setup-xampp.bat」ファイルを実行します。


MySQLログ設定

SQLログを出力するため、「%XAMPP_HOME%\mysql\bin\my.cnf」ファイルに以下の設定を追加します。

[mysqld]
log=sql.log
MySQLデータベース設定

必要であれば、MySQLのデータベースを作成、特権を作成します。「%XAMPP_HOME%\xampp-control.exe」ファイルを実行、Apache HTTP ServerとMySQLを起動、Webブラウザで「http://localhost/」にアクセス、phpMyAdminMySQLデータベースを操作します。


JBoss Application Server

ダウンロード、展開

JBoss Application Server」をダウンロード、「C:\eclipse」フォルダに展開します。「C:\eclipse\jboss-x.x.x」フォルダが作成されます。


データソース設定

「%JBOSS_HOME%\docs\examples\jca\mysql-ds.xml」を「%JBOSS_HOME%\server\default\deploy\mysql-ds.xml」にコピーし、内容を修正します。

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
	<local-tx-datasource>
		<jndi-name>MySqlDS</jndi-name>
		<connection-url>jdbc:mysql://localhost:3306/test</connection-url>
		<driver-class>com.mysql.jdbc.Driver</driver-class>
		<user-name>root</user-name>
		<password></password>
		<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
		<metadata>
			<type-mapping>mySQL</type-mapping>
		</metadata>
	</local-tx-datasource>
</datasources>

は、XAMPPでMySQLを設定していればその設定にします。


Jad

ダウンロード、展開

Jad」をダウンロードします。ただし、2009/4/18時点ではJadの公式サイトが閉鎖しており、「Internet Archive」からダウンロードできます(参考: JADの行方 - Java Solution - @IT)。

ダウンロードしたファイルを「C:\eclipse」に展開します。「C:\eclipse\jadntxxx」が作成されます。


Eclipse

ダウンロード、展開

Eclipse IDE for Java EE Developers」をダウンロード、「C:\eclipse」フォルダに展開します。「C:\eclipse\eclipse」フォルダが作成されます。


eclipse.iniの変更

「C:\eclipse\eclipse\eclipse.ini」ファイルを変更します。

-vmargs
-Xms256m
-Xmx256m
workspaceの作成

ワークスペースを「C:\eclipse\workspace」に作成します。


設定

以下のように設定します。

[Preferences]
	[General]
		Always run in background=True
		Show heap status=True
		[Appearance]
			[Colors and Fonts]
				Basic/
					Text Font=MS ゴシック, 標準, 9
		[Editors]
			[Text Editors]
				Undo history size=9999
				Insert spaces for tabs=True
				Show line numbers=True
				[Spelling]
					Enable spell checking=False
		[Network Connections]
			System proxy configuration (if available)=True
		[Workspace]
			Text file encoding=Other UTF-8
			New text file line delimiter=Other Windows
	[Java]
		[Build Path]
			Folders=True
			Source folder name=src/main/java
			Output folder name=target/classes
		[Code Style]
			[Code Templates]
				Comments/
					Types=/**
 * <p>
 * </p>
 * @version $$Id$$
 */
					Fields=/**
 * <p>
 * ___${field}___。
 * </p>
 */
					Getters=/**
 * <p>
 * ___${bare_field_name}___を返します。
 * </p>
 * @return ___${bare_field_name}___。
 */
					Setters=/**
 * <p>
 * ___${bare_field_name}___を設定します。
 * </p>
 * @param ${param} ___${bare_field_name}___。
 */
				Code/
					Getter body=return this.${field};
			[Formatter]
				「Eclipse [built-in]」を元に新しいプロファイルを作成。
					Indentation/
						Tab policy=Spaces only
						Statements within 'switch' body=True
					Blank Lines/
						Before package declaration=1
						Before first declaration=1
						Before field declarations=1
					New Lines/
						at end of file=True
					Line Wrapping/
						Maximum line width=9999
					Comments/
						Javadoc comment settings/
							Remove blank lines=True
						Block comment settings/
							Remove blank lines=True
						Maximum line width for comments=9999
		[Compiler]
			Compiler compliance level=1.6
		[Editor]
			[Content Assist]
				[Auto-Activation]
					Enable auto activation=False
			[Save Actions]
				Perform the selected actions on save=True
					Format source code=True
		[JadClipse]
			Path to decompiler=C:\eclipse\jadnt158\jad.exe
	[JavaScript]
		[Code Style]
			[Formatter]
				「Eclipse [build-in]」を元に新しいプロファイルを作成。
					Indentation/
						General settings/
							Tab policy=Spaces only
						Indent/
							Statements within 'switch' body=True
					New Lines/
						Insert new line/
							at end of file=True
					Line Wrapping/
						Line width and indentation levels/
							Maximum line width=9999
					Comments/
						General settings/
							Enable header comment formatting=True
						Jsdoc comment settings/
							Remove blank lines=True
						Line width/
							Maximum line width for comments=9999
		[Editor]
			[Save Actions]
				Perform the selected actions on save=True
					Format source code=True
	[Team]
		[CVS]
			[Label Decorations]
				Text Decorations/
					Outgoing Change flag=■
					Added flag=◆
		[SVN]
			[ラベル装飾]
				テキスト/
					発信のラベル装飾=■
					追加のラベル装飾=◆
					外部のラベル装飾=●
	[Validation]
		Disable All
	[Web]
		[CSS Files]
			Encoding=ISO 10646/Unicode(UTF-8)
			[Editor]
				Line width=9999
				Indent using spaces=Selected
				Indentation size=4
		[HTML Files]
			Encoding=ISO 10646/Unicode(UTF-8)
			[Editor]
				Line width=999
				Indent using spaces=Selected
				Indentation size=4
		[JSP Files]
			Encoding=ISO 10646/Unicode(UTF-8)
	[XML]
		[XML Files]
			[Editor]
				Line width=999
				Preserve whitespace in tags with PCDATA content=True
				Indent using spaces=True
				Indentation size=4
SVN設定

SVNリポジトリエクスプローラー」パースペクティブを開いて、既存のSVNリポジトリに接続するように設定します。


DBサーバ設定

「Database Development」パースペクティブを開いて、XAMPPのMySQLに接続するように設定します。


アプリケーション・サーバ設定

「Servers」ビューを右クリックして「New」→「Server」をクリック、JBossを使用するように設定します。

「Servers」ビューにJBossが追加されたらそれをダブル・クリックし、「Overview」を開きます。その中の「Timeouts」を開き、「Start」「Stop」を適切な値に設定します(例えば、Start = 180、Stop = 60)。


Java SE Development Kit

ダウンロード、展開

Java SE Development Kit」をダウンロード、通常の場所にインストールします。その後、「C:\eclipse\eclipse\jre」フォルダにインストールしたファイルをコピーします。


zipアーカイブ

「C:\eclipse」フォルダをzipアーカイブします。他のPCで作業するときは、これを展開するだけでJava開発環境を構築できます。