diff --git a/java/src/processing/mode/java/Compiler.java b/java/src/processing/mode/java/Compiler.java index b68e6df73..cfe9eb97d 100644 --- a/java/src/processing/mode/java/Compiler.java +++ b/java/src/processing/mode/java/Compiler.java @@ -68,6 +68,7 @@ public class Compiler { //"-noExit", // not necessary for ecj "-source", "1.7", "-target", "1.7", + "-encoding", "utf8", "-classpath", build.getClassPath(), "-nowarn", // we're not currently interested in warnings (works in ecj) "-d", build.getBinFolder().getAbsolutePath() // output the classes in the buildPath diff --git a/java/src/processing/mode/java/JavaBuild.java b/java/src/processing/mode/java/JavaBuild.java index 9b2f9c771..1001ad14b 100644 --- a/java/src/processing/mode/java/JavaBuild.java +++ b/java/src/processing/mode/java/JavaBuild.java @@ -24,6 +24,8 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA package processing.mode.java; import java.io.*; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; @@ -249,14 +251,15 @@ public class JavaBuild { outputFolder.mkdirs(); // Base.openFolder(outputFolder); final File java = new File(outputFolder, sketch.getName() + ".java"); - final PrintWriter stream = new PrintWriter(new FileWriter(java)); + BufferedWriter bw = Files.newBufferedWriter(java.toPath(), StandardCharsets.UTF_8); + final PrintWriter stream = new PrintWriter(bw); try { result = preprocessor.write(stream, bigCode.toString(), codeFolderPackages); } finally { stream.close(); } - } catch (FileNotFoundException fnfe) { - fnfe.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); String msg = "Build folder disappeared or could not be written"; throw new SketchException(msg);