1

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~

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~

And I get this error:

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

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
[...]

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.

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

Thank you.

Alexxx
  • 766
  • 1
  • 11
  • 19
  • 1
    Java tends to use the default ANSI codepage on Windows. The console uses the OEM codepage. Try using `CHCP` to switch the terminal to ANSI (e.g. 1252 for Western latin.) – McDowell Jan 08 '13 at 15:07
  • Yeah! You're my hero ;) It's woking! Thank – Alexxx Jan 08 '13 at 15:15

1 Answers1

0

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

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>
Alexander Kjäll
  • 4,246
  • 3
  • 33
  • 57
  • Ok, you're right, I probably must use Ant to compile my java project instead making my horrible bat tools. But I don't want to install all the software avaible on the earth to do a little thing. I've already have JDK and a native bat file processing under windows. That must be enough! But thank you for the reply. – Alexxx Jan 08 '13 at 15:19