How to Install (then Test) the NetBeans Bundle Contents 1. OVERVIEW... 1 2. CHECK WHAT VERSION OF JAVA YOU HAVE... 2 3. INSTALL/UPDATE YOUR JAVA COMPILER... 2 4. INSTALL NETBEANS BUNDLE... 3 5. CREATE A TEST WEB APPLICATION PROJECT... 4 6. VIEW YOUR PAGE... 5 7. SELECT YOUR BROWSER FROM NETBEANS... 5 8. RUN YOUR PAGE... 6 9. TEST THAT YOU WILL BE ABLE TO WRITE WEB APIS... 6 1. Overview As you can see from the Contents above, in this lab, you will install the NetBeans bundle and then test that it works. The NetBeans bundle is several different pieces of software that are pre-configured to work together. The best thing about installing the bundle is that you do not have to mess around with configuration settings or trying to get each piece of software to recognize the others. It just works. The NetBeans Bundle includes: NetBeans (open source java editor and compiler), Apache (open source web server software), and Tomcat/Glassfish (two different open source JSP servers) this is needed later in the semester when we will create JSP Web APIs. If you do not already have a java SDK (software development kit) installed, you will have to do that first. It is very important (for your success in this course) to be sure that you have a good working development environment at home! Page 1
2. Check What Version of java You Have NetBeans needs for you to have a java compiler installed on your PC/MAC the java compiler is called java JDK (Java Development Kit). If you have just taken Data Structures, it is likely that you already have a java compiler installed on your computer. However, right now (January 2019), the NetBeans bundle needs for you to have: version 1.8 of the Standard Edition (SE) java JDK NetBeans would probably also work with slightly earlier JDK versions but there is a bug right now that prevents it from working properly with version 1.9 or 1.10. So, if you have JDK 1.9 and/or JDK 1.10, uninstall them (and do not say yes if your computer asks if you want to update your version of java). There are various ways to find out which version of javac you have installed on your computer. On a PC, you can look for the names of folders inside of C:\Program Files\Java As you can see from the above screen capture, I have version 1.8 of the JDK. When you install the JDK, you also get the JRE. For your information: The JDK is the java compiler (translates java to java byte code) and the JRE is the java runtime (enables java byte code to run on your computer). On a MAC, you might use your finder to locate your java version (Google for more help with this). 3. Install/Update your java Compiler If you need to install the JDK, Google download java and select a link like the one below. When you get to the Oracle JDK download page, you will find links for your operating system. If you have a recent PC, it is likely that you need the bottom link for Windows x64. If your PC is older, then it would be the link above that Windows x86. There s only one link for MAC. Page 2
4. Install NetBeans Bundle Once you are sure you have the right version of the java compiler installed on your computer, you are ready to download/install the NetBeans Bundle. Google download NetBeans to get to this page: https://netbeans.org/downloads/8.0.2/ Select the latest version that offers all technologies (right bottom download). We will need NetBeans to be bundled with the Apache Web server and the Glassfish JSP application server. Take this one Page 3
5. Create a Test Web Application Project After installing NetBeans, test to make sure it works by creating a simple Web Application project as described below. Click on "File New Project" Under Categories, select Java web Under Projects select Web Application. Type in a project name. For grading purposes, please include your last name in your project name, for example, YOURNAME_web. Then accept all other defaults, clicking Next, until the wizard is finished. Once the wizard is done, you should see your new web application project in the NetBean's project pane (as shown below). If you open up that project, you'll see a folder called "Web Pages" with a file index.html inside. If index.html is not already opened up in the editor pane (right side), double click on it. You ll see a simple template for an HTML page. In the edit area, replace the text that says "TODO write content" with "Hello World" then save the file. Replace TODO write content with "hello world" inside the <div>..</div> Page 4
6. View Your Page To View your HTML page: Right click anywhere in the edit area and select "View". NetBeans will open up your index.html in a browser (showing hello world ). Because you Viewed the page, you should see the file name and path in the address bar. I like to View pages when I am working on my CSS, laying out my page, because it is a bit faster than running the page (discussed below). Note: If all you wanted to do is edit and view HTML, you could use any editor (including NotePad) and any browser. You could double click on your html file from File Explorer (would bring up the browser with your page in it), then edit your file, save it, then refresh your browser. However, you would not get a lot of context sensative help and error checking. Also, you would not have the ability to Run your page (see below). 7. Select Your Browser From NetBeans Even though Firefox may not be your favorite browser, Firefox provides better syntax error checking. When you you right click a page and View Source from Firefox, you ll see syntax errors in red font. So, try using Firefox just until you are sure your HTML and CSS do not have any syntax errors in them. To set the NetBeans default browser, Click on Tools Options (General tab should already be selected) and select Firefox. Once we start using javascript (and not focusing so much on CSS/layout), we ll use Chrome because it has a really nice javascript debugging environment. Page 5
8. Run Your Page If your page needs the HTTP protocol (for example once you start making AJAX calls which you will be doing even in your first homework), you need to have Apache serve up your web page. To do this, Right click anywhere in the editor pane and select Run (not View). The first time you run a page, there is a slight delay while NetBeans deploys your web application. Notice the difference in the URL it shows localhost as your domain, not just the file name as before when you Viewed your page. 8080 is the port number that the web server uses to listen for web page requests. 9. Test That You Will Be Able To Write Web APIs Later in this course, you will be writing Server Side code that responds to JavaScript requests from your web pages. We will use JSP pages for this. Test that your installation can run JSP pages, so that if there is a problem you have more time to fix it. Right click on the Web Pages folder (in the project pane) and select New - JSP You can accept the default file name of newjsp. Double click newjsp to open it in the editor. Run the page by right clicking anywhere in the editor area and selecting Run If you see newjsp.jsp in the browser s address bar and Hello World displaying, then you have properly installed the NetBeans bundle and you will be able to write Web APIs later in the semester. Page 6