Downloading Java from the command line has always been troublesome. What I have been doing reciently is to use FireFox (other browsers might work) to get a download started on my laptop, pause it (within the Downloads windows), use the "Copy Download Link" menu item of the context menu displayed for the downloading file. This URL can then be used on the Linux box to download the same file. I expect the URL has a short time to live. Ugly, but generally successful.
jdk 8u5 windows x64 23
I am using ubuntu 14.04 [free tier eligible] on AWS cloud, and am running the code from 64 bit windows8.1 laptop. I am using PUTTY to connect to the server instance. I git cloned the pnda code from to the ubuntu instance.
Hi does anyone know how to do this in Groovy or Java? I've tried the following Groovy code but I get an EmptyInputStream returned.def address = " -pub/java/jdk/7u45-b18/jre-7u45-windows-x64.tar.gz"def file = new FileOutputStream(address.tokenize("/")[-1])def out = new BufferedOutputStream(file)URL url = new URL(address);HttpURLConnection conn = url.openConnection();//proxy settingsSystem.setProperty("http.proxyHost", proxyHost);System.setProperty("http.proxyPort", proxyPort); conn.setFollowRedirects(true);//conn.setRequestProperty("Cookie", "gpw_e24=http%3A%2F%2Fwww.oracle.com%2F");conn.setRequestProperty("Cookie", "gpw_e24=http"); conn.setAllowUserInteraction(false);conn.connect();InputStream is = conn.getInputStream();byte[] buffer = new byte[BUFFER_SIZE];int numRead = 0; while ((numRead = is.read(buffer)) != -1) out.write(buffer, 0, numRead);out.close()println "done"
import java.net.HttpURLConnection;import java.net.URLConnection;Downloader downloader = new Downloader()downloader.download(" -pub/java/jdk/7u45-b18/jre-7u45-windows-x64.tar.gz");class Downloader def fileName; def download(address) println "downloading from " + address fileName = address.tokenize("/")[-1] URL url = new URL(address); HttpURLConnection conn = url.openConnection(); conn.setRequestProperty("Cookie", "gpw_e24=http%3A%2F%2Fwww.oracle.com%2F"); conn.setAllowUserInteraction(false); //this won't handle re-directs from http to https we need to handle that ourselves conn.setInstanceFollowRedirects(true); conn.connect(); processResponse(conn); def processResponse(HttpURLConnection conn) int status = conn.getResponseCode(); println("Response Code = " + status); if (status == HttpURLConnection.HTTP_OK) readInputStream(conn); else def handleRedirect(HttpURLConnection conn) println "handling redirect" String newUrl = conn.getHeaderField("Location"); println "new URL is " + newUrl; // open the new connnection again conn = (HttpURLConnection) new URL(newUrl).openConnection(); conn.setRequestProperty("Cookie", "gpw_e24=http%3A%2F%2Fwww.oracle.com%2F"); processResponse(conn); def readInputStream(HttpURLConnection conn ) def out = new BufferedOutputStream(new FileOutputStream(fileName)); long fileSize = Long.parseLong(conn.getHeaderField("Content-Length")); InputStream is = conn.getInputStream(); try byte[] buffer = new byte[1024 * 10]; int numRead = 0; long processedBytes = 0; while ((numRead = is.read(buffer)) != -1) out.write(buffer, 0, numRead); processedBytes += numRead; println "processed $processedBytes bytes of $fileSize" finally out.close() is.close(); println "done"
I have worked on both Java and Microsoft .Net in my career and I like both of them. Recently I noticed some exciting activities in the Java and the open source society and started to pick up Java again. The first thing that I do is to pick an IDE. According to a recent study, Eclipse is the most popular IDE for Java development. This study note is a step by step instruction on how to set up Eclipse. In this study note, I will set up Eclipse on a windows 64-bit computer. If you are using Linux, you are probably already an expert on Eclipse. If not, this study note should at least have some reference values for you, because the overall principles are the same.
If you do not already have a desired Java Run-time environment on your computer, you will need to install one. You can go to the Oracle website to download it. You can choose to download either a JRE or a JDK. For most of the functions in Eclipse, a JRE should be sufficient. But I noticed that if you want to develop a Dynamic Web Project, and if you want to debug it with a J2EE Preview server, you will need a JDK to power the Eclipse IDE. In this study note, I chose the JDK version (Java SE 8U5) for windows 64-bit computers and installed it to the default location.
You can go to the official Eclipse website to download the desired version of Eclipse. In this study note, I downloaded the Eclipse Kepler (4.3.2). There are many Eclipse packages to choose from. Since I will be doing a lot of web application development, I choose the "Eclipse IDE for Java EE Developers" for windows 64-bit computers. The following is the downloaded zip file from the Eclipse website. 2ff7e9595c
Comments