2014年2月27日木曜日

Velocity HTML 出力

resolver で vm 指定するのではなく、通常の html としてファイル出力し、ブラウザから静的にロードする。

pom.xml へ Velocity 設定追加
<dependency>
    <groupId>org.apache.velocity</groupId>
    <artifactId>velocity</artifactId>
    <version>1.7</version>
</dependency>

src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml へリソースディレクトリ定義追加
<resources mapping="/html/**" location="/html/" />

src/main/webapp/WEB-INF/spring/root-context.xml へ velocityEngine 定義追加
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
    <property name="resourceLoaderPath" value="/WEB-INF/velocity" />
    <property name="velocityPropertiesMap">
        <map>
            <entry key="input.encoding" value="UTF-8" />
            <entry key="output.encoding" value="UTF-8" />
        </map>
    </property>
</bean>

Velocityテンプレートファイル
/WEB-INF/velocity/sample.vm
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title>サンプルタイトル</title>
</head>
<body>
    <ul id="data">
    #foreach ($data in $datalist.entrySet())
        <li>
        $data.key
        $data.value
        </li>
    #end
    </ul>
</body>
</html>

コントローラ
jp.s6131.sample.controller.HomeController.java
@Autowired
VelocityEngine velocityEngine;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(HttpServletRequest req, Locale locale, Model model) {
・・・
Map<String, Object> param = new HashMap<String, Object>();
Map<String, String> data = new HashMap<String, String>();
for (int i = 0; i < 10; i++) {
    data.put(String.format("%05d", i), String.format("名称%02d", i));
}
param.put("datalist", data);
try {
    String outputFile = req.getSession().getServletContext().getRealPath("/html/sample.html");
    logger.debug("output html = " + outputFile);
    OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(outputFile), "utf-8");
    VelocityEngineUtils.mergeTemplate(velocityEngine, "sample.vm", param, osw);
    osw.close();
} catch (Exception ex) {
    ex.printStackTrace();
}

http://localhost:8080/sample アクセス後、
http://localhost:8080/sample/html/sample.html にアクセスし、作成済 HTML を確認。


人気ブログランキングへ

2014年2月25日火曜日

MyBatis 3 テーブル書込、トランザクション

src/main/webapp/WEB-INF/spring/root-context.xml へトランザクション設定追加
<bean id="transactionManager"    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource">
        <ref local="dataSource" />
    </property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>

サービスinterface
jp.s6131.sample.service.SampleService.java
package jp.s6131.sample.service;
・・・
public interface SampleService {
    ・・・
    public int insertList(List<Sample> sampleList);
}

サービス
jp.s6131.sample.service.impl.SampleServiceImpl.java
package jp.s6131.sample.service.impl;
・・・
@Service("sampleService")
public class SampleServiceImpl implements SampleService {
    @Autowired
    SampleMapper sampleMapper;
    ・・・
    @Override
    @Transactional
    public int insertList(List<Sample> sampleList) {
        int rtnTotal = 0;
        for (Sample sample : sampleList) {
            int rtn = sampleMapper.insert(sample);
            logger.debug("insert rtn = " + rtn);
            rtnTotal += rtn;
        }
        return rtnTotal;
    }
}

コントローラ
jp.s6131.sample.HomeController.java
@Autowired
SampleService sampleService;
・・・
List<Sample> sampleList = new ArrayList<Sample>();
for (int i = 0; i < 10; i++) {
    Sample sample = new Sample();
    sample.setCode("000000000" + (i + 1));
    sample.setName(String.format("Name%04d", i));
    sampleList.add(sample);
}
int rtn = sampleService.insertList(sampleList);
logger.debug("rtn = " + rtn);

実行ログ
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ooo Using Connection [com.mysql.jdbc.JDBC4Connection@61fc1ea]
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==>  Preparing: insert into sample (id, code, name ) values (?, ?, ? )
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==> Parameters: null, 0000000001(String), java.io.StringReader@4b9bc91d(StringReader)
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - <==    Updates: 1
DEBUG: jp.s6131.sample.service.impl.SampleServiceImpl - insert rtn = 1
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ooo Using Connection [com.mysql.jdbc.JDBC4Connection@10cd263e]
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==>  Preparing: insert into sample (id, code, name ) values (?, ?, ? )
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==> Parameters: null, 0000000002(String), java.io.StringReader@25d4cfde(StringReader)
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - <==    Updates: 1
DEBUG: jp.s6131.sample.service.impl.SampleServiceImpl - insert rtn = 1
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ooo Using Connection [com.mysql.jdbc.JDBC4Connection@2c4f00de]
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==>  Preparing: insert into sample (id, code, name ) values (?, ?, ? )
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==> Parameters: null, 0000000003(String), java.io.StringReader@3bfa2596(StringReader)
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - <==    Updates: 1
取得するコネクションが毎回違い、トランザクションが効いていない。
  • log4j.xml で Spring のログレベルを全て debug にしてもエラー等無く、原因が不明。
  • ネットで検索するとサービスが Spring に認識されていない事が原因らしいが、具体的な対応方法は不明。

対応した方法
servlet-context.xml でデフォルトで
<context:component-scan base-package="jp.s6131.sample>
となっていたのを
<context:component-scan base-package="jp.s6131.sample.controller>
とし、controller パッケージに HomeController.java を移動。

root-context.xml に
<context:component-scan base-package="jp.s6131.sample.service"/>
を追加し、サービスを具体的に検索対象に指定。

変更後の実行ログ
DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ooo Using Connection [com.mysql.jdbc.JDBC4Connection@1042ce9b]DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==>  Preparing: insert into sample (id, code, name ) values (?, ?, ? ) DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==> Parameters: null, 0000000001(String), java.io.StringReader@2fc64742(StringReader)DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - <==    Updates: 1DEBUG: jp.s6131.sample.service.impl.SampleServiceImpl - insert rtn = 1DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ooo Using Connection [com.mysql.jdbc.JDBC4Connection@1042ce9b]DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==>  Preparing: insert into sample (id, code, name ) values (?, ?, ? ) DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==> Parameters: null, 0000000002(String), java.io.StringReader@b3a0261(StringReader)DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - <==    Updates: 1DEBUG: jp.s6131.sample.service.impl.SampleServiceImpl - insert rtn = 1DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ooo Using Connection [com.mysql.jdbc.JDBC4Connection@1042ce9b]DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==>  Preparing: insert into sample (id, code, name ) values (?, ?, ? ) DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - ==> Parameters: null, 0000000003(String), java.io.StringReader@1997ce1a(StringReader)DEBUG: jp.s6131.sample.mapper.SampleMapper.insert - <==    Updates: 1
コネクションが同じものを使用する様になり、トランザクションが効くようになった。


人気ブログランキングへ

2014年2月22日土曜日

MyBatis 3 テーブル読込

pom.xml へ spring-jdbc 組込み
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>${org.springframework-version}</version>
</dependency>

src/main/webapp/WEB-INF/spring/root-context.xml へ jdbc 設定と mybatis 設定
<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName">
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
        <value>jdbc:mysql://localhost/sample</value>
    </property>
    <property name="username">
        <value>s6131</value>
    </property>
    <property name="password">
        <value>s6131</value>
    </property>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mapperLocations">
        <list>
            <value>classpath:jp/s6131/sample/mapper/*.xml</value>
        </list>
    </property>
</bean>
<bean class="org.mybatis.spring.SqlSessionTemplate">
    <constructor-arg ref="sqlSessionFactory" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="jp.s6131.sample.mapper" />
</bean>

サービスinterface
jp.s6131.sample.service.SampleService.java
package jp.s6131.sample.service;
・・・
public interface SampleService {
    public List<Sample> selectByCode(String code);
}

サービス
jp.s6131.sample.service.impl.SampleServiceImpl.java
package jp.s6131.sample.service.impl;
・・・
@Service("sampleService")
public class SampleServiceImpl implements SampleService {
    @Autowired
    SampleMapper sampleMapper;
    @Override
    public List<Sample> selectByCode(String code) {
        SampleExample sampleExample = new SampleExample();
        sampleExample.createCriteria().andCodeEqualTo(code);
        List<Sample> sampleList = sampleMapper.selectByExampleWithBLOBs(sampleExample);
        return sampleList;
    }
}

コントローラ
jp.s6131.sample.HomeController.java
@Autowired
SampleService sampleService;
・・・
sampleList = sampleService.selectByCode("001");
for (Sample sample : sampleList) {
    logger.debug("code = " + sample.getCode() + " name = " + sample.getName());
}


人気ブログランキングへ

2014年2月21日金曜日

Eclipse MyBatis 3 Generator インストール


pom.xml に

  • MySQL jdbc ドライバ
  • MyBatis 3
  • MyBatis-Spring 連携

を追加。
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.2.4</version>
</dependency>
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>1.2.2</version>
</dependency>
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.29</version>
</dependency>

MyBatis Generator インストール
svn から github にサイトが変わった為、eclipse での新規ソフトウェアのインストールではなく、手動でインストール。
  • https://github.com/mybatis/generator
Download ZIP ボタンを選択してダウンロード。
ダウンロードした generator-master.zip から eclipse/UpdateSite/plugins の最新バージョンの
  • org.mybatis.generator.core_バージョン.jar
  • org.mybatis.generator.eclipse.core_バージョン.jar
  • org.mybatis.generator.eclipse.ui_バージョン.jar
を c:\pleiades\eclipse\plugins にコピー、eclipse 再起動。
eclipse「新規」「その他」「MyBatis」「MyBatis Generator Configuration File」 で generationConfig.xml を作成。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC
  "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
  "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration >
  <classPathEntry location="/Users/ユーザー/.m2/repository/mysql/mysql-connector-java/5.1.29/mysql-connector-java-5.1.29.jar"/>
  <context id="context1" >
    <jdbcConnection
      driverClass="com.mysql.jdbc.Driver"
      connectionURL="jdbc:mysql://localhost/sample"
      userId="s6131"
      password="s6131" />
    <javaModelGenerator
      targetPackage="jp.s6131.sample.model"
      targetProject="sample" />
    <sqlMapGenerator
      targetPackage="jp.s6131.sample.mapper"
      targetProject="sample" />
    <javaClientGenerator
      targetPackage="jp.s6131.sample.mapper"
      targetProject="sample"
      type="XMLMAPPER" />
    <table schema="sample" tableName="sample" />
  </context>
</generatorConfiguration>
generatorConfig.xml 右クリック「Generate MyBatis/iBATIS Artifacts」で以下自動作成

  • jp.s6131.sample.mapper.SampleMapper.java
  • jp.s6131.sample.mapper.SampleMapper.xml
  • jp.s6131.sample.model.Sample.java
  • jp.s6131.sample.model.SampleExample.java


人気ブログランキングへ

2014年2月20日木曜日

Windows 8.1 64bit MySQL 5.6.16 64bit インストール

MySQL for Excel 1.2.0 をインストールする際、

  • The Microsoft Visual Studio Tools for Office Runtime

がインストール済みでないとエラーとなる。以下からダウンロード。

  • http://www.microsoft.com/ja-jp/download/details.aspx?id=40790

エクスプローラで vstor_redist.exe を選択、インストール。

MySQL インストール
  • http://dev.mysql.com/downloads/mysql/
Window (x86, 32-bit), MSI Installer をダウンロード。
インストーラーは 32bit だが、バイナリは 32bit と 64bit を含んでいる。

エクスプローラで mysql-installer-community-5.6.16.0.msi を選択、インストール。
  • Setup Type で custom を選択しないと 32bit/64bit の選択が出来ない。
  • 32bit を選択すると、MySQL Server の 5.6 が選択出来なくなる。(5.5 は可)
  • インストール先が c:\Program Files なので(x86 ではなく)おそらくデフォルトだと 64bit。
  •  32bit を選択してから <Back するとインストール先が c:\Program Files(x86) になる。
  • MySQL workbench が 32bit 版しかない為、VCランタイムも 32bit 版 がインストールされる。
  • インストーラで <Back とか色々やっていると、最終的にインストールするプロダクト一覧に選択していないプロダクトが入ってしまったりするので、インストーラを再起動。
custom を選択して 5.6 64bit を選択し、インストール。

MySQL Server Configuration の設定
  • Open Firewall port for network access のチェックを外す
  • Show Advanced Options のチェックを入れる
  • ユーザー s6131 を権限 DB Admin で追加

show variables で設定値を確認
  • query_cache がデフォルトだと OFF になっているが、現行困らないのでそのまま。


人気ブログランキングへ

2014年2月19日水曜日

Apache Commons Imaging EXIF 更新

EXIF より GPS情報のみ削除する
try {
    IImageMetadata metadata = Imaging.getMetadata(new File("c:\\Temp\\test.jpg"));
    if (!(metadata instanceof JpegImageMetadata)) {
        return null;
    }
    JpegImageMetadata jpegMetadata = (JpegImageMetadata)metadata;
    TiffImageMetadata exif = jpegMetadata.getExif();
    if (exif == null) {
        return null;
    }
    TiffOutputSet outputSet = exif.getOutputSet();
    if (outputSet == null) {
        return null;
    }
    TiffOutputDirectory gpsDirectory = outputSet.getGPSDirectory();
    if (gpsDirectory == null) {
        return null;
    }
    List<TiffOutputField> gpsFieldList = gpsDirectory.getFields();
    for (TiffOutputField field : gpsFieldList) {
        gpsDirectory.removeField(field.tagInfo);
    }
    new ExifRewriter().updateExifMetadataLossless(
            new File("c:\\Temp\\test.jpg"),
            new FileOutputStream(new File("c:\\Temp\\test2.jpg")),
            outputSet
        );
} catch (Exception ex) {
    ex.printStackTrace();
}


人気ブログランキングへ

2014年2月18日火曜日

Apache Commons Imaging EXIF 表示

pom.xml へ Commons Imaging 追加
<repositories>
    <repository>
        <id>apache.snapshots</id>
        <url>http://repository.apache.org/snapshots/</url>
    </repository>
</repositories>

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-imaging</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

EXIF 表示サンプルコード
try {
    IImageMetadata metadata = Imaging.getMetadata(new File("c:\\Temp\\test.jpg"));
    if (metadata instanceof JpegImageMetadata) {
        JpegImageMetadata jpegMetadata = (JpegImageMetadata)metadata;
        TiffImageMetadata exif = jpegMetadata.getExif();
        List<? extends IImageMetadataItem> dirs = exif.getDirectories();
        for (int i = 0; i < dirs.size(); i++) {
            TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs.get(i);
            logger.debug("dir type = " + dir.type);
            List<TiffField> fieldList = dir.getAllFields();
            for (TiffField tiffField: fieldList) {
                logger.debug("tagInfo tag = " + tiffField.getTagInfo().tag);
                logger.debug("tagInfo name = " + tiffField.getTagInfo().name);
                if (FieldType.UNDEFINED.equals(tiffField.getFieldType())) {
                    logger.debug("field value = " + tiffField.getValueDescription());
                } else {
                    logger.debug("field value = " + tiffField.getValue());
                }
            }
        }
    }
} catch (Exception ex) {
    ex.printStackTrace();
}

ログを出力する為、log4j.xml を変更
<logger name="jp.s6131.sample">
    <level value="debug" />
</logger>


人気ブログランキングへ

2014年2月17日月曜日

Jmagick アニメーションGIF サイズ変更

Jmagick に coalesceImages と deconstructImages のメソッドを追加する。

  • magick_MagickImage.c
/*
 * Class:     magick_MagickImage
 * Method:    coalesceImages
 * Signature: ()Lmagick/MagickImage;
 */
JNIEXPORT jobjectArray JNICALL Java_magick_MagickImage_coalesceImages
    (JNIEnv *env, jobject self)
{
    int i, imageLength;
    jclass magickImageClass = 0;
    Image *image = NULL, *coalesceImages = NULL;
    jobject newObj;
    jobjectArray newObjArray;
    ExceptionInfo exception;
    image = (Image*) getHandle(env, self, "magickImageHandle", NULL);
    if (image == NULL) {
        throwMagickException(env, "Cannot retrieve image handle");
        return NULL;
    }
    GetExceptionInfo(&exception);
    coalesceImages = CoalesceImages(image, &exception);
    if (coalesceImages == NULL) {
        throwMagickApiException(env, "Cannot coalesce image", &exception);
        DestroyExceptionInfo(&exception);
        return NULL;
    }
    DestroyExceptionInfo(&exception);
    imageLength = GetImageListLength(coalesceImages);
    magickImageClass = (*env)->FindClass(env, "magick/MagickImage");
    if (magickImageClass == 0) {
        return NULL;
    }
    newObjArray = (*env)->NewObjectArray(env, imageLength, magickImageClass, NULL);
    if (newObjArray == NULL) {
        throwMagickException(env, "Unable to construct newObjArray[]");
        return NULL;
    }
    for (i = 0; i < imageLength; i++){
        newObj = newImageObject(env, GetImageFromList(coalesceImages, i));
        if (newObj == NULL) {
            DestroyImageList(coalesceImages);
            throwMagickException(env, "Unable to create coalesce image");
            return NULL;
        }
        (*env)->SetObjectArrayElement(env, newObjArray, i, newObj);
    }
    return newObjArray;
}
/*
 * Class:     magick_MagickImage
 * Method:    deconstructImages
 * Signature: ()Lmagick/MagickImage;
 */
JNIEXPORT jobject JNICALL Java_magick_MagickImage_deconstructImages
    (JNIEnv *env, jobject self)
{
    Image *image = NULL, *deconstructImage = NULL;
    jobject newObj;
    ExceptionInfo exception;
    image = (Image*) getHandle(env, self, "magickImageHandle", NULL);
    if (image == NULL) {
        throwMagickException(env, "Cannot retrieve image handle");
        return NULL;
    }
    GetExceptionInfo(&exception);
    deconstructImage = DeconstructImages(image, &exception);
    if (deconstructImage == NULL) {
        throwMagickApiException(env, "Cannot deconstruct image", &exception);
        DestroyExceptionInfo(&exception);
        return NULL;
    }
    DestroyExceptionInfo(&exception);
    newObj = newImageObject(env, deconstructImage);
    if (newObj == NULL) {
        DestroyImageList(deconstructImage);
        throwMagickException(env, "Unable to create deconstruct image");
        return NULL;
    }
    return newObj;
}
  • MagickImage.java
/**
 * Merge a sequence of images.
 * @exception MagickException on error
 */
public native MagickImage[] coalesceImages()
  throws MagickException;
/**
 * Break down an image sequence into constituent parts.
 * @exception MagickException on error
 */
public native MagickImage deconstructImages()
  throws MagickException;
修正後、コマンドプロンプト(管理者)で Make を実行
cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64"
vcvarsx86_amd64.bat
cd \pleiades\workspace\6.6.9\src
nmake -f Makefile.all

サンプルコード実行 
try{
    MagickImage mi = new MagickImage(new ImageInfo("c:\\Temp\\in.gif"));
    MagickImage[] moArray = mi.coalesceImages();
    for (int i = 0; i < moArray.length; i++) {
        moArray[i] = moArray[i].resizeImage(200, 200, 1);
    }
    MagickImage mo = new MagickImage(moArray).deconstructImages();
    mo.setFileName("c:\\Temp\\out.gif");
    mo.writeImage(new ImageInfo());
} catch (Exception ex) {
    ex.printStackTrace();
}


人気ブログランキングへ

2014年2月16日日曜日

Windows 8.1 64bit JMagick インストール

pleiades の java には include が無いので jdk インストール
エクスプローラでダウンロードした jdk-7u51-windows-x64.exe ファイルを選択、インストール。
C:\Program Files\Java\jdk1.7.0_51\include を C:\Pleiades\java\7\include へコピー。

JMagick の取得
  • 「ウィンドウ」「パースペクティブを開く」「その他」「SVN リポジトリ・エクスプローラー」
  • 「SVN リポジトリー」ウィンドウで右クリック「新規」「リポジトリーロケーション」
  • 「URL:」に https://svn.code.sf.net/p/jmagick/code/ を指定
  • branches の最新バージョンを右クリックして「チェックアウト」

Makefile の編集
  • c:\Pleiades\workspace\6.6.9\win32\Makefile.all を c:\Pleiades\workspace\6.6.9\src にコピー
  • c:\Pleiades\workspace\6.6.9\src\Makefile.all を編集

include および 64bit Lib 指定 
CPPINC=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
CPPLIB=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\amd64

JDK ディレクトリ指定
JDKDIR=C:\Pleiades\java\7

ImageMagick ディレクトリ指定
MAGICKDIR=C:\Program Files\ImageMagick-6.8.8-Q16

コンパイラフラグ
CPP_FLAGS= \
    /nologo /MT /w /EHsc /Od /Gs0 /Fo"$(INTDIR)\\" /c /favor:AMD64 \
    /D "WIN64" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" \
    /D "JMAGICK_EXPORTS"  /D "_VISUALC_" /I "$(CPPINC)" \
    /I "$(JNIINC)" /I "$(JNIINC)/win32" /I "$(MAGICKINC)" \
    /I "$(GENDIR)" /I "$(SRCDIR)" /I "$(MAGICKINCDIR)"
リンクフラグ
LINK32_FLAGS= \
    "$(MAGICKLIB)" \
    /nologo /dll /incremental:no /machine:x64 \
    /libpath:"$(CPPLIB)" \
    /out:"$(OUTDIR)\jmagick.dll" \
    /implib:"$(OUTDIR)\jmagick.lib" \
    /NODEFAULTLIB:msvcrt.lib \
    /MANIFEST
Java コンパイラオプション
CLASSES :    $(SRCDIR)\*.java $(SRCDIR)\util\*.java
    "$(JDKBIN)\javac" -source 1.5 -target 1.5 -d $(CLSDIR) -classpath $(SRCDIR) -sourcepath $(SRCDIR) $(?)

コマンドプロンプト(管理者)を実行
cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64"
vcvarsx86_amd64.bat
cd \pleiades\workspace\6.6.9\src
mkdir ..\classes
nmake -f Makefile.all
link 時に未解決の外部シンボルエラーが発生する。
を参照し、「Deprecated, replace with:」で書かれたメソッドへ変更する。
  • AcquireMemory は AcquireMagickMemory に変更した。
  • JMagick のメソッド自体が deprecate な場合は丸ごとコメント化。

make 処理中で
  • jmagick.jar を C:\Pleiades\java\7\lib\ext
  • jmagick.dll を C:\Program Files\ImageMagick-6.8.8-Q16
にコピーする。

jmagick.jar アクセス制限解除
  • 「プロジェクトのプロパティ」「Java のビルド・パス」「ライブラリー」「アクセス・ルール」「編集」「追加」
  • 「レゾリューション」を「アクセス可能」
  • 「ルール・パターン」を「magick/*」

Javaサンプルコード(画像リサイズ)を実行して動作確認
try{
  MagickImage mi = new MagickImage(new ImageInfo("c:\\Temp\\sample.jpg"));
    MagickImage mo = mi.scaleImage(300,300);
mo.setFileName("c:\\Temp\\out.jpg");
mo.writeImage(new ImageInfo());
} catch (Exception ex) {
ex.printStackTrace();
}


人気ブログランキングへ

2014年2月15日土曜日

Windows 8.1 64bit ImageMagick インストール


ImageMagick Win64 dynamic at 16 bits-per-pixel をダウンロード。


エクスプローラでダウンロードした ImageMagick-6.8.8-6-Q16-x64-dll.exe ファイルを選択、
インストール。
インストール途中のオプションで Install development headers and libraries for C and C++ を
選択しておく。

スタートメニュー右クリック、コマンドプロンプトを開き、convert動作確認。
Version: ImageMagick 6.8.8-5 Q16 x64 2014-02-08 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsvg tiff webp xml zlib
Usage: convert.exe [options ...] file [ [options ...] file ...] [options ...] file


人気ブログランキングへ

Windows 8.1 Visual Studio Express インストール

Visual Studio Express 2013 for Windows Desktop をダウンロード。

エクスプローラでダウンロードした wdexpress_full.exe ファイルを選択、インストール。

スタートメニュー右クリック、コマンドプロンプトを開く。環境設定用バッチを起動。
cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64"
vcvarsx86_amd64.bat

cl コマンドでコンパイラが動作することを確認。
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64>cl
Microsoft(R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.
使い方: cl [ オプション... ] ファイル名... [ /link リンク オプション... ]


人気ブログランキングへ

2014年2月14日金曜日

Spring MVC サンプルプロジェクト作成

  • 「ファイル」「新規」「その他」「Spring」「Spring プロジェクト」「Spring MVC Project」を選択
  • プロジェクト名を設定「sample」、次へ
  • トップレベルパッケージを設定「jp.s6131.sample」、完了。Maven4 の sample プロジェクトが作成される

プロジェクトの JRE が 1.6 なので 1.7 に変更する。
  • 「パッケージ・エクスプローラー」から sample プロジェクトを右クリック、「プロパティー」
  • 「Java のビルド・パス」「ライブラリー」「JRE システム・ライブラリー[JavaSE-1.6]」「編集」
  • 「実行環境」で「JavaSE-1.7(java7)」を選択、完了。
  • 「プロジェクト・ファセット」「Java」のバージョンを 1.6 から 1.7 へ変更、OK。

サーバーを作成する。
  • 「ファイル」「新規」「その他」「サーバー」「サーバー」
  • 「サーバーのタイプを選択」で「Tomcat v7.0 サーバー」を選択、次へ
  • 「Tomcat インストール・ディレクトリー」に「c:\pleiades\tomcat\7」を選択
  • 「JRE」に「java7」を選択、次へ
  • 「sample」プロジェクトを「追加」、完了

サーバービューを表示し、サーバーを起動
  • 「ウィンドウ」「ビューの表示」「その他」「サーバー」「サーバー」
  • 「ローカル・ホストの Tomcmat v7.0 サーバー[停止,再公開]」を右クリック、「デバッグ」を選択
  • Web ブラウザから「localhost:8080/sample/」でサンプルページ表示を確認する。


人気ブログランキングへ

2014年2月13日木曜日

Eclipse Spring プラグイン インストール

「ヘルプ」「Eclipse マーケットプレース」
  • 「検索」で「spring kepler」を検索
  • 「Spring Tool Suite (STS) for Eclipse Kepler (4.3) 3.4.0.RELEASE」をインストール
  • インストール後、Eclipse 再起動

Spring Tool Tips/Dashboard を Startup 時に非表示にする。

「ウィンドウ」「設定」「SpringSource」
  • 「Show Spring Tool Tips on startup」のチェックを外す。
  • 「Dashboard」「Show Dashboard On Startup」のチェックを外す。


人気ブログランキングへ

2014年2月12日水曜日

Windows 8.1 Kepler 64bit Java インストール

Pleiades Kepler 64bit Java Full Edition をダウンロード。


エクスプローラでダウンロードした zip ファイルを選択、
中にある pleiades ディレクトリを c:\ へD&Dして解凍。

Eclipse の起動
  • c:\pleiades\eclipse\eclipse.exe を選択

java6 がデフォルトになっているので java7 へ変更。

「ウィンドウ」「設定」「Java」
  • 「インストール済みの JRE」で Java7 を選択
  • 「コンパイラー」「コンパイラー準拠レベル」で 1.7 を選択

Tomcat6 がデフォルトになっているので Tomcat7 へ変更。

「ウィンドウ」「設定」「Tomcat」
  • 「Tomcat バージョン」でバージョン 7.x を選択
  • 「Tomcat ホーム」を C:\pleiades\tomcat\7 に変更
  • 「JVM設定」「JRE」で java7 を選択


人気ブログランキングへ