{"id":8824,"date":"2014-08-04T05:04:08","date_gmt":"2014-08-03T19:04:08","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=8824"},"modified":"2014-08-04T05:04:08","modified_gmt":"2014-08-03T19:04:08","slug":"java-http-client-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/java-http-client-primer-tutorial\/","title":{"rendered":"Java Http Client Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Java\/HttpClient\/Java_HttpClient.jpg\"><img decoding=\"async\" id='hci' style=\"float:left; border: 15px solid pink;\" alt=\"Java Http Client Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Java\/HttpClient\/Java_HttpClient.jpg\" title=\"Java Http Client Primer Tutorial\" onmouseover=\" document.getElementById('hci').src = document.getElementById('hci').src.replace('.jpg', '.PNG').replace('.png', '.jpg').replace('.PNG', '.png');  \"   \/><\/a><p class=\"wp-caption-text\">Java Http Client Primer Tutorial<\/p><\/div>\n<p>With a Mac laptop you have a Linux (Bash) environment you can access via the Terminal application.  From there, if you have Java installed you can compile Java programs using the <i>javac<\/i> compiler command and then execute the resultant Java .class program (today we create ClientHttp.class via <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/Java\/HttpClient\/ClientHttp.java_GETME' title='ClientHttp.java'>ClientHttp.java<\/a> programmable source code) via <i>java ClientHttp &lt;URL&gt; [&lt;filename&gt;]<\/i> &#8230; but please note that Java works with Windows too, or Unix and Linux (only) operating systems.   It is to a great degree platform-independent.<\/p>\n<p>Because I started this sentence with &#8220;because&#8221;, and also because the methodology of the ClientHttp Java program today (inspired in a huge degree by <i>Java in a Nutshell<\/i> by David Flanagan pp. 189-191) which connects to a Web server (today we use our local MAMP web server via <i>java ClientHttp http:\/\/localhost:8888\/sn.html sncopy.htm<\/i> &#8230; where <a target=_blank title='sn.html' href='http:\/\/www.rjmprogramming.com.au\/Java\/HttpClient\/sn.html_GETME'>sn.html<\/a> is just this small HTML webpage, with the program output of <a target=_blank title='sncopy.htm' href='http:\/\/www.rjmprogramming.com.au\/Java\/HttpClient\/sncopy.htm_GETME'>sncopy.htm<\/a>) and downloads the specified URL, is based around <i>Sockets<\/i>, so please read <a id='afterchspt' href='#mybq' title='Socket information from Wikipedia ... thanks'>below<\/a>, from Wikipedia &#8230; and you may want to compare and contrast this to our previous <a href='#chspt' onmouseover=' setTimeout(backagain, 7000); ' title='C# Socket Primer Tutorial'>C# Socket Primer Tutorial<\/a> as shown below (as well).<\/p>\n<p><script> function backagain() { location.href = '#afterchspt';  }<\/script><\/p>\n<p>Hope you enjoy <a target=_blank title='Java Http Client Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/Java\/HttpClient\/Java_HttpClient.jpg'>the<\/a> <a target=_blank title='Java Http Client Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/Java\/HttpClient\/Java_HttpClient.png'>tutorial<\/a> in which we communicate with a local (MAMP) web server in order to download the contents of webpages of designated URLs, using Java.<\/p>\n<p>Link to Socket information from <a target=_blank title='socket information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Network_socket'>Wikipedia<\/a>, from where the quote in the previous tutorial below, originated.<\/p>\n<hr \/>\n<p id='chspt'>Previous relevant <a target=_blank title='C# Socket Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=4801'>C# Socket Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/CHash\/Socket\/CHash_socket_Primer.jpg\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"C# Socket Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/CHash\/Socket\/CHash_socket_Primer.jpg\" title=\"C# Socket Primer Tutorial\"   \/><\/a><p class=\"wp-caption-text\">C# Socket Primer Tutorial<\/p><\/div>\n<p>C# using Visual Studio on Windows is a great language to  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/VB.NET\/VBdotNet-Windows-Form-Desktop-Application-VisualStudio.png'>learn<\/a>.   If you like C# you may eventually like VB.Net, and vice versa.   It has sophisticated data structures, can be Object Oriented and makes great Windows desktop applications or can be the code behind an ASP.Net website or web application.     <\/p>\n<p>C# and VB.Net have Visual Studio support for functionality to do with networking and the use of sockets, as described below at Wikipedia.<\/p>\n<blockquote id='mybq'><p>A network socket is an endpoint of an inter-process communication flow across a computer network. Today, most communication between computers is based on the Internet Protocol; therefore most network sockets are Internet sockets.<\/p>\n<p>A socket API is an application programming interface (API), usually provided by the operating system, that allows application programs to control and use network sockets. Internet socket APIs are usually based on the Berkeley sockets standard.<\/p>\n<p>A socket address is the combination of an IP address and a port number, much like one end of a telephone connection is the combination of a phone number and a particular extension. Based on this address, internet sockets deliver incoming data packets to the appropriate application process or thread.<\/p><\/blockquote>\n<p>Hope you enjoy the <a target=_blank title='C# Socket Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/CHash\/Socket\/CHash_socket_Primer.jpg'>tutorial<\/a> in which we create a socket for communications using the http protocol to a host of your choosing &#8230; we chose google.com &#8230; you will need to have your internet connection working and check that the firewall settings allow port 80 to communicate with a socket.   In this tutorial we establish a socket and make a request and receive a response.   In practice you would continue on with more sophistication.<\/p>\n<p>Here is some downloadable C# programming source code which you might want to rename to <a target=_blank title='Program.cs' href='http:\/\/www.rjmprogramming.com.au\/CHash\/Socket\/Program.cs_GETME'>Program.cs<\/a><\/p>\n<p>The Socket Class <a target=_blank title='Socket tutorial from Microsoft' href='http:\/\/msdn.microsoft.com\/en-us\/library\/system.net.sockets.socket.aspx'>tutorial<\/a> was used and amended only slightly for this tutorial, so please start here on the path to further examination of this very interesting and fundamental area of network programming.<\/a><\/p>\n<p>Link to Socket information from <a target=_blank title='socket information from Wikipedia' href='http:\/\/en.wikipedia.org\/wiki\/Network_socket'>Wikipedia<\/a>, from where the quote above came.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d4801' onclick='var dv=document.getElementById(\"d4801\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=C%23\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d4801' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d4801' onclick='var dv=document.getElementById(\"d4801\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=C%23\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d4801' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>With a Mac laptop you have a Linux (Bash) environment you can access via the Terminal application. From there, if you have Java installed you can compile Java programs using the javac compiler command and then execute the resultant Java &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/java-http-client-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,25,37],"tags":[644,707,744,837,997,1164,1319,1411],"class_list":["post-8824","post","type-post","status-publish","format-standard","hentry","category-elearning","category-networking","category-tutorials","tag-java","tag-linux","tag-mamp","tag-networking-2","tag-programming","tag-socket","tag-tutorial","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/8824"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=8824"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/8824\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=8824"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=8824"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=8824"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}