Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java files can't be compiled if they contain package statement ☕ #86

Open
alirezaopmc opened this issue Jul 14, 2022 · 0 comments
Open

Comments

@alirezaopmc
Copy link

alirezaopmc commented Jul 14, 2022

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:
image

Output:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant