javac @< opiton_file>和编码 [英] javac @<opiton_file> and encoding

查看:100
本文介绍了javac @< opiton_file>和编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在法语Windows 7下编译我的计算机上的一些java文件;和我的东西我有一些麻烦的文件endoding ...

I'm trying to compile some java files on my computer under Windows 7 in french; and I thing I have some trouble with file endoding...

在第一步,我生成一个文件列表编译:

In a first step, I'm generating a list of the file to compile:

dir src\*.java /B/S > javasrc.tmp~

这将在文件javasrc.tmp〜中逐行写入路径的java文件(递归)的目录src。在我的情况下,我有:

Which will wrote in the file "javasrc.tmp~" line by line the full path of java file (recursivly) of the directory src. In my case I have :

C:\Users\Alexandre\Développement\Java\src\testA.java
C:\Users\Alexandre\Développement\Java\src\testB.java
[...]

(注意,我的完整路径中有一个重音字母)

(Note that there is an accentued letter into my full path)

使用以下命令编译所有源文件:

In a second step, I compile all the source file with the following command:

"%JAVA_HOME%\bin\javac.exe" @javasrc.tmp~

我得到这个错误:

javac: file not found: C:\Users\Alexandre\Développement\Java\src\testA.java

在Notepad ++中打开我的javasrc.tmp〜文件时,文件显示为:

When opening my javasrc.tmp~ file in Notepad++ the file is displayed as:

C:\Users\Alexandre\D,veloppement\Java\src\testA.java
C:\Users\Alexandre\D,veloppement\Java\src\testB.java
[...]

字母显示为逗号;我必须选择OEM 863文件编码才能正确显示文件的内容。

The accentued letter is display as a comma; and I have to select OEM 863 file encoding to display the content of the file correctly.

那么如何解决我的问题呢? (我使用这些命令作为bat文件中的自动化过程)。

So how to solve my problem? (I'm using these commands as an automated process in a bat file).

谢谢。

推荐答案

最好的方法是改为ant或maven,而不是bat文件。

The best way would be to change to ant or maven, instead of bat files. It's more standard and also more portable.

一个基本的ant文件将被命名为build.xml,如下所示:

A basic ant file would be named build.xml and look something like this:

<project name="My Project Name Here" basedir="." default="main">

<property name="lib.dir" value="lib"/>

<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</path>

<property name="src.dir" value="src"/>

<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>

<property name="main-class" value="My Main Class Name Here"/>

<target name="clean">
<delete dir="${build.dir}"/>
</target>

<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
</target>

<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>

<target name="run" depends="jar">
<java fork="true" classname="${main-class}">
<classpath>
<path refid="classpath"/>
<path location="${jar.dir}/${ant.project.name}.jar"/>
</classpath>
<arg value="RIMM" />
</java>
</target>

<target name="clean-build" depends="clean,jar"/>

<target name="main" depends="clean,run"/>

</project>

这篇关于javac @&lt; opiton_file&gt;和编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆