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

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

问题描述

我正在尝试在我的计算机上用法语在 Windows 7 下编译一些 java 文件;我觉得我在文件结束时遇到了一些麻烦...

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~"文件中将一行一行的写入src目录下java文件的完整路径(递归).就我而言,我有:

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:UsersAlexandreDéveloppementJavasrc	estA.java
C:UsersAlexandreDéveloppementJavasrc	estB.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%injavac.exe" @javasrc.tmp~

我收到此错误:

javac: file not found: C:UsersAlexandreDéveloppementJavasrc	estA.java

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

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

C:UsersAlexandreD,veloppementJavasrc	estA.java
C:UsersAlexandreD,veloppementJavasrc	estB.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天全站免登陆