In: Computer Science
Lab 1. Java and the Command Prompt a) Visit the Java SE JDK website and see which version of Java you need to download. b) If granted permissions, try to see how to modify environment variables (PATH and CLASSPATH). c) Open the command prompt/shell. Use cd and dir (ls on UNIX-like systems) commands to navigate your file system and see what files do you have in different locations e.g. on your flash drive. Pay attention to the file extensions. d) Use move (mv on UNIX-like systems) to rename and move some files of your choice. e) Get a sample Java program, compile and run it.
a) Search JAVA SE JDK in search engine. First website link will take you to java downloads page. There you can see the latest version of java available for download as shown in following image.
After this you can download and install java on your system. I already have previous version of java installed in my system so, i am not downloading it now.
b) how to modify environment variables (PATH and CLASSPATH) ?
I am using windows 7. To set environment variable values you need to click on windows "Start" button. Then Go to "Computer" and right click on it, then go to "properties" it will open the following window.
click on "Advanced system settings" then click on "Environment Variables" in lower right corner. Following window will appear.
Now, click on "New" button under "User variables" section and enter the "Variable name = path" and "Variable value = C:\Program Files\Java\jdk-11\bin" as shown in following image
Click ok on every opened window.
Your environment variables are set now.
c) Open the command prompt/shell. Use cd and dir (ls on UNIX-like systems) commands to navigate your file system and see what files do you have in different locations
Use "dir" command to see present directories. i used "dir" command to see my present directories as shown in following image
Output shows various directories and system files present in C drive for user "KK".
Now we use "cd" command to change our directory. I used "cd Desktop" command to move to "Desktop" directory as shown in following image.
I again used "dir" command to see various files and directories present in my Desktop directory as shown in following image
When we observe output of dir command. we can see various files present on desktop. File extension we found in Desktop directory are, .pdf = Portable document fromat, .zip file format used to compress files, .jpg and .png formats used to represent picture format. .xls format used to represent Microsoft excel sheet.
e) Get a sample Java program, compile and run it.
Open Notepad and type the following simple java code and save that file as A.java in your Desktop directory As shown in following image.
Now, open a command prompt window and use "cd Desktop" command to change current directory to Desktop.
To compile A.java, Type "javac A.java" in command prompt and press enter.
After that to run A.java, Type "java A" in command prompt and press enter. It will print the "Hello World" as output of your java program as shown in following image.