![]() Step 6: Navigate to the JUnit Installation Folder Step 4: Select the JUnit Configure OptionĪ screenshot showing this is provided below.Ĭlick the “ Browse” button, as shown in the screenshot below: These files need to be saved in the folder/directory which you created in the previous step.Įxactly how you perform the download depends on which Web browser you're using.įor both Firefox and Chrome, you can right-click the above links and choose “ Save Link As.”, and then navigate to the target folder/directory and save.Įxactly how you do this depends on your particular configuration. There are two binary files which you need to download, listed below: Step 2: Download JUnit Installation Files If you're unsure of what to name this folder/directory, the name junit_setup will work. The exact name or location of the folder/directory doesn't particularly matter, though the folder/directory should be in a relatively permanent location which you can easily reference later on.įor example, if you have a USB drive which you carry between the lab and home, it'd be good to put this folder on the USB drive. Step 1: Create a Folder/Directory for JUnit Installation FilesĬreate a folder/directory where you will later save some JUnit installation files. Once jGrasp has been configured to use JUnit, you do not need to fo through these configuration instructions again. The instructions below accomplish just that. However, unlike with the JDK, jGrasp cannot automatically figure out where JUnit is, so we need to configure it to know where it can find JUnit. This is analogous to the fact that jGrasp has built-in support for the Java Development Kit (JDK), but it does not come preinstalled with the JDK. While jGrasp has built-in support for JUnit, it does not come preinstalled with JUnit. This guide covers two big things related to JUnit: You can see the output of your code in the window at the bottom, in the same location you looked for compiler errors in the previous step.Testing in jGrasp Using JUnit Testing in jGrasp Using JUnit You can run your code by selecting Build -> Run, as illustrated in the image below. If your code compiled successfully in the previous step, then you'll be able to run it. The image below also shows that HelloWorld.class has appeared in the same folder/directory as HelloWorld.java. In the case of the image below, there were no errors it shows that javac was run and subsequently exited normally.īecause javac was successful, a class file was produced, namely HelloWorld.class. If compilation doesn't succeed, error messages will be shown in the window at the bottom, illustrated in the image below. Note that compilation won't necessarily succeed.įor example, the compiler will reject your code if it has a syntax error, which includes things like forgetting to match a left brace ( ). You can tell jGrasp to compile your code by selecting Build -> Compile, as shown in the image below. Internally, jGrasp performs this by running javac, though it hides this detail from you. Once your code is written, you can try to compile it. Once you have selected a place to save the file along with the filename, hit the Save button. While you can save your code with a different filename, you won't actually be able to compile and run your code later.Īssuming your code contains a class definition (e.g., public class Foo), jGrasp will automatically choose a correct filename (in this case, Foo.java). In Java, the filename must always match the name of the class you have created in the file.įor example, if the class name is Foo, then the code must be saved in a file named Foo.java. ![]() Selecting Save will allow you to choose exactly where you want to save the file, along with what the filename should be. You can save the file by selecting File -> Save from the menu, as shown in the image below. You will need to save the file explicitly before you can actually compile or run your code. While you have been working with a file in jGrasp, it has not yet been saved to the computer. When you ask jGrasp to create a new file, an embedded window will appear wherein you can write and edit your code. You can create a new Java source file by selecting File -> New -> Java. JGrasp can be downloaded here (look for the “Download” link on the top left you can skip the survey and scroll straight to the bottom).Įxactly how you do this depends on your particular configuration. This guide assumes that you already have jGrasp installed, which is preinstalled on the lab machines. Compiling and Running Java Code with jGrasp Compiling and Running Java Code with jGrasp
0 Comments
Leave a Reply. |