95-702 Distributed Systems Lab 1 Part 1. Command line execution

advertisement
95-702DistributedSystems Lab1
Part1.Commandlineexecutionandcompilation
Youmayhavelittleornoworktodointhispart.
TesttoseeifyourpathvariableissettopointtotheJDK/bindirectoryby
runningthefollowingcommandsfromacommandprompt.Thismustbetested
inadirectoryotherthanyourJDKbindirectory.
● java–version
● javac–version
Theversionshouldbethesamenumberandshouldbegreaterthanorequalto7.
IfthetestfailstheneitheryouhavenoJDKinstalledoryourpathvariableisnot
set.
IfyouhavenoJDKinstalled(theJREaloneisnotsufficient)thenfollowthese
instructions.
1. DownloadtheJDKforyourconfigurationfrom
http://www.oracle.com/technetwork/java/javase/downloads/jdk8downloads-2133151.html
2. Youmayneedtocreateaprofilebeforeyoucandownload
3. InstalltheJDKandacceptallthedefaults.Seedirectionsforuninstalling
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk
.html
ForMac:
4. ForMac,itsetstheentireconfigurationsettingbyitselfandfurther
softwareinstallationslikeNetbeansandAndroidstudioshouldbeableto
picktheinstallationdirectoryandconfiguration.
5. Ifyoudonotseeanychangesfromtheolderversion,tryuninstallingthe
oldjavafirst.See
https://www.java.com/en/download/help/mac_uninstall_java.xml
ForWindows:
6. Inwindows,youshouldcheckiftheJAVA_HOMEandPathvariablesare
set.Followthefollowingsteps:
7. RightclickonMyComputerandselectproperties.Ifusinganewversion
ofWindowstrytofindThisPC.
8. Clickon“AdvancedSystemsettings”inthelefthandtopofthewindow.
9. Clickon“EnvironmentVariables”tobringtheuservariablesandsystem
variables
10. ConfirmthatJAVA_HOMEissetunder“UserVariables”.Itmustbesettoa
JDKandnotaJRE.Forexample,onasystemwithJDK6itmightbesetto
C:\MyJava\Java\jdk1.6.0_10.
11. ConfirmthatthePathissetunderthe“SystemVariables”.Thepath
variableshouldbesettotheJDK’sbindirectory.Forexample,thepath
variablemightbesettoC:\MyJava\Java\jdk1.6.0_10\bin.
12. IftheJAVA_HOMEisnotset,clicknewunder“UserVariables”andspecify
the“VariableName”asJAVA_HOMEand“VariableValue”asthe
installationdirectoryofyourJDK–notthebindirectory.
13. IfthePathvariableisnotset,clicknewunder“SystemVariables”and
specifythe“VariableName”asPathand“VariableValue”as{installation
directoryofyourJDK}\bin.
14. AftersettingtheJAVA_HOMEandPathvariable,NetBeansandAndroid
StudioshouldbeabletopicktheJavainstallationdirectory.
Note:Ifthepathhasembeddedspaces,placedoublequotesaroundthepath.
Note:MakesurethepathtoyourJDK/bindirectoryisthefirstpathinyourpath
variable.
Part2.InstallationofNetbeans
FollowthesestepstoinstallNetBeans:
1. Gotohttps://netbeans.org/downloads/
2. Underthe“All”column,clickon“Download”buttonfortheNetBeansIDE
downloadbundles.
3. IfyouareinstallingNetBeansonaMacthenfollowthefollowingsteps.If
youareusingawindowssystemjumptostep9
ForMacUsers:
4. Clickonthe“netbeans-8.x.x-macosx.dmg”filedownloadedonthesystem.
Typicallythefileispresentin“Downloads”folder.
5. Clickonthe“netbeans-8.x.x-macosx.pkg”filetostarttheinstallation.
6. Itmightaskforaconfirmation:“Thispackagewillrunaprogramto
determineifthesoftwarecanbeinstalled.”.Pleaseclickcontinue
7. BrowsethroughthestandardinstallationwindowandinstallNetBeans
8. AfterinstallationNetBeanswouldbeavailablein“Launchpad”ofMac.
ClickontheiconandstartNetBeans
ForWindowsUser:
9. Clickonthe.exefileandselectallthedefaultsandclickfinish.
10. Theinstallationwouldbeavailableinthestartmenu/applications.
Part3.Debuggingpracticeexercise
1. DownloaddebuggingExerciseLab1.zipfromcoursewebpage
2. OpennetbeansandimporttheprojectbyFile->ImportProject->From
Zip..
3. Applybreakpointsatline20and23byrightclickingontherespective
linesandselecting“ToggleLineBreakpoint”.Thiswillallowyoutostopthe
executionofthecodeataparticularpointandenableyoutoseethevaluesof
variableswhicharegeneratedatruntime.
4. RightClickonDebugging.javaontheleftpanelundertheprojects->
DebuggingExerciseLab1->SourcePackages->lab1andselect“DebugFile”
5. Whentheexecutionpausesatline20pressF8tostepovertothenextline
ofcode.Nowhoverthemouseover‘number’torecordthevalueofthevariable.
6. Similarlykeepsteppingoverlinestogetthevalueof‘result’wheni=3.
Part4.Togaincreditforthislab:
1) ShowaTAthatyouareabletorunjava–versionandjavac–versionfrom
thecommandline(overvariousdirectories).
2) ShowyourTAthatyouhaveNetbeansinstalledandworking.
3) PerformthedebugginginfrontoftheTA.
4) Whatisthevalueofnumber?__________
5) Whatisthevalueofresultwheni=3?__________
Download