Skip to content

Commit

Permalink
fix: fix Java
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 22, 2021
1 parent b96d7f5 commit 1798f08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions examples/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
// test UTF-8
System.out.println("سلام");
}
}
9 changes: 4 additions & 5 deletions lib/grammars/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ export const Java = {
const className = GrammarUtils.Java.getClassName(context)
const classPackages = GrammarUtils.Java.getClassPackage(context)
const sourcePath = GrammarUtils.Java.getProjectPath(context)
const tempFolder = GrammarUtils.createTempFolder("jar-")
const cmd = `javac -encoding UTF-8 -sourcepath '${sourcePath}' -d '${tempFolder}' '${context.filepath}' && java -D'file.encoding'='UTF-8' -cp '${tempFolder}' ${classPackages}${className}`
if (windows) {
return [`/c javac -Xlint ${context.filename} && java ${className}`]
return [`/c ${cmd}`]
} else {
return [
"-c",
`javac -J-Dfile.encoding=UTF-8 -sourcepath '${sourcePath}' -d /tmp '${context.filepath}' && java -Dfile.encoding=UTF-8 -cp /tmp:%CLASSPATH ${classPackages}${className}`,
]
return ["-c", cmd]
}
},
},
Expand Down

0 comments on commit 1798f08

Please sign in to comment.