Sharif-Judge
Sharif-Judge copied to clipboard
Java files can't be compiled if they contain package statement ☕
Consider this java code:
package something;
class SomeClass {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
This must be compiled using javac according to the package name. In fact to compile this java code it must be moved to a directory called something
. Then It can be compiled using javac something/SomeClass.java
. But the tester.sh
does not do this operation currently.
You can see the shell command executed for java files here:
if [ "$EXT" = "java" ]; then
cp ../java.policy java.policy
cp $PROBLEMPATH/$UN/$FILENAME.java $MAINFILENAME.java
shj_log "Compiling as Java"
javac $MAINFILENAME.java >/dev/null 2>cerr
...
This is annoying if the students structure their code in some directories with package statements.
A real example code:
Output: