Issue
I'm doing a Coursera course that require you to submit programming assignments.
The specification says the following.
We recommend that when testing your solution locally, you use the same compiler flags for compiling. This will increase the chances that your program behaves in the same way on your machine and on the testing machine (note that a buggy program may behave differently when compiled by different compilers, or even by the same compiler with different flags).
javac -encoding UTF-8
java -Xmx1024m
I read many answers online instructing how to set flags for C++/C code.
Go to Project > Properties > C/C++ Build > Settings > Cross G++ Compiler > Miscellaneous
But I couldn't find a similar option (eg - Java Build) in Java.
How do I add this flag when compiling the program.
I'm using Neon version of eclipse.
Solution
javac
Eclipse uses its own compiler, not javac; and I don't think it accepts command line flags the way javac does. But there are many compiler options, which you can find under Window | Preferences | Java | Compiler
java
To pass arguments to java at run time, click the drop-down triangle next to the Run button on the toolbar (the one that looks like a white triangle inside a green circle). Go down to "Run Configurations". Here, you can set up a number of options for when you run your program. In particular, flags such as -Xmx1024m
can be entered in the "VM Arguments" box on the "Arguments" tab.
Answered By - Dawood ibn Kareem