![]() ![]() Please be careful to choose to download JDK and not JRE. JRE just allows you to run other people's Java programs, not compile and create your own programs. Note: Sun updates JDK frequently by the time you read these directions, it may be JDK 6 Update 17 or something like that. Our screenshot below is probably out of date by now as well, since we don't update it unless the page appearance changes.Īccept the License Agreement and choose the "Windows Platform, Offline Installation, Multi-language JDK file": jdk-6u16-windows-i586.exe (73.54 MB) The directions should be the same otherwise. Once you have finished downloading this file to your Desktop, you must install JDK on your system. Do this by double-clicking the JDK installer file you saved on the Desktop. You can choose all the default options during installation.įrom the jGRASP web site link above, click the button at top-right labeled Download jGRASP. You will be taken to a download page with some survey information. Underneath the survey is a set of buttons. Click the jGRASP exe to download a file named jgrasp187_02.exe. Save the file to your Desktop or another convenient location.NOTE: If you use Windows Vista, you may need to choose to "Download Jar File" rather than "Download Windows App.".Once you have finished downloading this file to your Desktop, you must install jGRASP on your system. Do this by double-clicking the jGRASP installer file you saved on the Desktop. (Our screenshots probably show an older version number, but the overall process is the same.)Įxtra information for Windows Vista 64-bit: Once you are done installing jGRASP, you should now have icons on your Desktop and in your Start Menu for running jGRASP. If you have Vista but aren't sure whether it's the 64-bit edition, you can follow these instructions to find out: We have had particular problems come up for students using Windows Vista 64-bit edition.Click on "System and Maintenance" (upper-left option).Now you should be seeing "basic information about your system", includingįor a system that is 64-bit, you will see something like the following (the note about 64-bit appears about three-quarters of the way down). ![]() 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. 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. |