Georgia Ingham Georgia is a Java Developer. She has spoken at lots of conferences. Her hobbies include reading, completing puzzle books and cycling.

How to use the Google App Engine with the NetBeans IDE

4 min read

cloud logo

At IDR Solutions I spend a lot of time on the Development of the JPedal Java PDF Library and PDF to HTML5 Converter. Recently I have spent a lot of time studying the cloud and thought it might be useful to create some guides on how to use various cloud platforms with the NetBeans IDE.

If you want to run a Java web application on the Google Cloud then you are going to have to become acquainted with the Google App Engine (GAE) which lets you build and run applications on Google’s infrastructure. For those of you who are looking to host an application that you have already created, please be aware that the GAE doesn’t support every class in the Java Runtime Environment. For example java.awt.Color isn’t supported but org.w3c.dom.css.RGBColor is.

What you will need before you start:

  • – Java 7 EE installed. Make sure it is set as your JAVA_HOME environment variable. We tried using Java 8 and encountered problems when using .jsp files
  • – Apache Maven installed. I would recommend adding Maven’s bin directory to your PATH environment variable because this will make your life easier later e.g. add this to the end of your current PATH ;C:\Program Files\apache-maven-3.3.3\bin
  • – Simple knowledge of how to operate your computer’s command line/terminal

1. Sign up for a Google Developer account

Before we can get started with the technical bits you have to be eligible to use the Google Cloud services. You can do this by either signing up for a 60-day free trial or by paying for the service. This page will give you some insight into what you can expect from the trial. Once you have successfully signed up you gain access to the Google Development Console, which will let you manage your application once it is deployed and other cloud resources.

2. Create a new Project on the Google Developer Console

You first register a new project in the Google Developer Console. Click the Create Project button and enter a project name. Each project has a project ID which will either be the same as your project’s name or a slightly different ID will be suggested. This is because the project ID must be globally unique and someone is already using that ID. Once you have clicked Create you will receive notifications on the browser to confirm your project was created. This will create your application’s host location e.g. yourProjectId.appspot.com

projectID

3. Download the Google App Engine SDK

Download the SDK from Google Cloud. You have to make sure you get the Java version as the page shows multiple. Once it has been downloaded, extract the zip from your downloads folder and save the extracted folder in your Program Files directory. e.g. C:\Program Files\appengine-java-sdk-1.9.26

googleSDK

4. Download the NetBeans Google App Engine plugin

This plugin will allow you to create and run a Google App Engine Server instance which is what we will use to deploy your applications to the Google Cloud Platform. Download the latest version. Gaelyk carried on the development of the plugin after Kenai created it but stopped development back in 2009. Make sure you download the most recent update. Again extract the download and place it in the Program Files directory

5. Add the Plugin to NetBeans

In your NetBeans IDE go to Tools menu and click the Plugins option. In the Plugins, window go to the Downloads tab and click Add Plugins. Navigate to where you saved the plugin in the Program Files directory and open all of the NetBeans Modules (.nbm). Click Install at the bottom left of the plugins window and an Installation Wizard will pop up. Accept the Licence Agreement and install the modules.

addPlugin

6. Create the Google App Engine Server instance

Go to your Services window, right-click on Servers and select the Add Server option. In the wizard select Google App Engine and click Next. For the installation location put the location of the SDK in the Program Files directory. e.g. C:\Program Files\appengine-java-sdk-1.9.26. You can leave the port numbers for now and change them later if need be. Click Finish. You should now have Google App Instance under Servers.

addServer

7. Create a Google App Engine Project

Now we can create a new Web Application. Go to the File menu and select New Project. In the Java Web category select Web Application. Fill in the name and location details for your project. On the Server and Settings screen select Google App Engine for the server. Java EE 5 is the only option for the Java EE version. Now click Finish and your project will be created.

googleAppSettings

8. Change Project ID

Below shows what your project’s file structure should resemble. To correctly deploy your application to the Google Cloud Platform you need to add your project Id to the appengine-web.xml file. Remember to save the file.

googleProjectId

9. Prepare the Project for Deployment

Right-click the project and there should be a Change email/password option. Here you should enter your Google Development Account credentials. Then right-click the project again and select Clean and Build which will compile the application for you.

10. First-time Deployment

This stage is needed for the very first deployment to Google App Engine. After you have completed this stage you will never have to carry this out for ANY other GAE project. I am using Windows so I will be using the command line. The commands will vary slightly for those on different Operating Systems.

Navigate to your Google App Engine SDK in your Program Files directory. Then use cd bin to navigate you in the SDK’s bin directory. From there you will need to run appcfg.cmd with the update argument and the path to your applications web directory e.g. appcfg update C:\Users\userName\Documents\NetBeansProjects\WebApplication1\web

If you get an error message related to JSP files or that you are pointing to the JRE instead of the JDK, then this may be due to your PATH environment variable. If you open up your PATH and see something along the lines of C:\ProgramData\Oracle\Java\javapath then you need to delete and replace this with the path to your current SDK’s bin directory. e.g. C:\Program Files\Java\jdk1.7.0_79\bin

commandPrompt

You should be asked for an authentication code. A web browser will be opened and you will be asked to sign in to your Google account if you are not signed in already. After that there will be a code displayed which you need to copy from your browser into the command line. You should see output similar to below if your application has been deployed correctly.

commandOutput

11. Deployment from here on

Like I said before you will not have to complete step 10 again. You can simply right-click your project in NetBeans and select the Deploy to Google App Engine option. Much simpler right?

12. View your application

To see your application running go to yourProjectId.appspot.com

And voila! There you have it, ladies and gentlemen. That is how to set up and deploy an application to the Google Cloud using the Google App Engine.

Next time I will be looking at ‘How to set up Amazon Cloud/AWS Elastic Beanstalk on the NetBeans IDE

Hopefully, you found this guide Tutorial useful, if you have not read my other cloud series articles be sure to check them out below:

If you want to try running Java Software on the Amazon and Azure Cloud you can try following these handy tutorials



Our software libraries allow you to

Convert PDF to HTML in Java
Convert PDF Forms to HTML5 in Java
Convert PDF Documents to an image in Java
Work with PDF Documents in Java
Read and Write AVIF, HEIC, WEBP and other image formats
Georgia Ingham Georgia is a Java Developer. She has spoken at lots of conferences. Her hobbies include reading, completing puzzle books and cycling.

27 Replies to “How to use the Google App Engine with the…”

  1. Thanks for the great tutorial on GAE deployment in Netbeans, Georgia. It really helped me a lot.

    There is only one little problem: I can deploy from the command line without a problem, but when I deploy in Netbeans, it seems to work fine without errors, but nothing is deployed.

    For the Google Development Account credentials, I put my Google email and password. Is this correct?

    Kind Regards,
    Hennie Reyneke

    1. Hi Hennie,
      I’m happy that is was helpful to you. You should enter your google account credentials there. Another possibility is that your Project Id doesn’t match your project in GAE in your appengine-web.xml file.
      Kind regards,
      Georgia

      1. Thanks for the reply and the advice, Georgia.

        Yes I did put my google account creds in there. And the application tag contains the Project ID. But it’s obviously a local problem here and I can live with it.

        A bigger problem is that JSF isn’t working. GAE seems to ignore the jstl tags.

        Take care,
        Hennie

        1. Hi Hennie,
          Sorry I won’t be able to help you there as I never used JSF when using GAE.
          Kind regards,
          Georgia

  2. Hi Georgia. Sorry, my mistake: I didn’t see that there was a new ‘Deploy to Google App Engine’ option in the drop-down (as you wrote!).

  3. I tried this link
    but I can’t complete  step 10
    I have the code it said about but how I can copy it in command line?

    1. I tried with this link and enter authentication code

      http://stackoverflow.com/questions/30383761/where-to-enter-oauth-in-netbeans-to-deploy-application-on-google-app-engine#new-answer

      but it didn’t complete
      it said:
      java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
      Unable to update app: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
      Please see the logs [C:\Users\MOHAME~1\AppData\Local\Temp\appcfg5740986809626681152.log] for further information.

  4. Hi Mohamed,
    The cause might be that your environmental variables are not set up correctly. If you open up your PATH environment variable and see something along the lines of C:\ProgramData\Oracle\Java\javapath then you need to delete and replace this with the path to your current SDK’s bin directory. e.g. C:\Program Files\Java\jdk1.7.0_79\bin

    Also NetBeans has its own path to the JDK set in a configuration file. You may have to update this too. You can see how to do that here

  5. My error is coming like
    java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
    Unable to update app: Cannot get the System Java Compiler. Please use a JDK, not a JRE.

    I changed the path ofenvironment variable from C:\ProgramData\Oracle\Java\javapath to C:\Program Files\Java\jdk1.7.0_79\bin.

    Then also same error is coming now what i can do to resolve it. And in the last comment you have mention that “Also NetBeans has its own path to the JDK set in a configuration file. You may have to update this too. ” But i am not able to getting it that how to change Netbeans path to current JDK.

    Please help me to resolve it.

    1. You can find the NetBeans configuration file (netbeans.conf) in the etc folder of where your NetBeans IDE is stored in program files e.g. C:\Program Files\NetBeans 8.1\etc\netbeans.conf
      Once you open that you need to change this line to which jdk you would like to use: netbeans_jdkhome=”C:\Program Files\Java\jdk1.8.0_60″
      Please note that the bin directory should not be added here and that JDK8 had a few issues when I was using it and so would not recommend using any of those versions.

      1. ingham i got the same error and when i try to open that conf file i find the same jdk in it
        what should i do else?

  6. Hi, I was following your tutorial (which worked great) but then when I tried to create an object on the index.jsp file I got this error: http://stackoverflow.com/questions/15950166/creating-an-object-within-a-jsp-page
    Eventually I came across this answer http://stackoverflow.com/questions/20762423/why-i-cannot-create-an-object-of-some-java-class-in-jsp-page and realized that the structure in the folder you mentioned at step 10 doesn´t have that structure.
    Instead I had to select this one: C:\Users\userName\Documents\NetBeansProjects\WebApplication1\build\web
    Maybe it’s something well known, but just in case..
    Thanks for the tutorial!

  7. Thank you, that’s a really usefull tutorial it worked fine august 2017.
    I’m looking for a tutorial on creating a webservice on GAE using Netbeans,
    i’m going to use it to connect to a database, it will be consumed by Android App,
    can you recommend a tutorial?

    Thank you!

  8. Thumbs.. In fact, Hands up for this. You don’t know how much help this has been. But I did everything right up till the deployment only for me to open the browser and get a 404 NOT_FOUND error.

    Any help will be so appreciated.
    Thanks.

  9. Georgia – thank you!
    Very glad I can now develop for GAE with Netbeans 8.2 (Win 10, jdk1.8.0_162).

    A few tips for fellow beginners that may save somebody some time:
    – No shortcuts; follow every step as presented.
    – I stumbled over this (common) error:
    "java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
    Unable to update app: Cannot get the System Java Compiler. Please use a JDK, not a JRE."

    This is clearly a PATH error, as mentioned by Georgia and others.
    Caution – I ended up confused with 3 diverging sets of the PATH environment variable info.
    A) Command Line (just type PATH in the command line and hit enter)
    B) In Control Panel->System and Security->Edit Environment Variables for your account
    C) In Control Panel->System and Security->Edit the system environment Variables
    I proceeded from A to C and was confused because the cmd console did not update my changes to the environment variables that I made via the control panel in steps B and C. Apparently it displays cached info when you ask it for the PATH.
    Closing the console and opening a new one updated the info for PATH.
    So I changed the PATH via the cmd line, but that did not resolve my “System Java Compiler” error.
    When you edit via B (ev for your account) the UI won’t let you edit the ev for the system.
    So – start at C with the system environment variables and work your way back. You can edit the ev for the current user via the UI in C. Delete the “Oracle” path in the PATH that points to the JRE. Then confirm the PATH via the command line.
    I also stumbled over Step 10 in Georgia’s instructions.
    "Set the path to your current SDK’s bin directory. e.g. C:\Program Files\Java\jdk1.8.0_162\bin"
    I pointed at the SDK installation folder, not the bin inside the installation folder.
    So I had to go back and reset the correct PATH in the control panel.
    Good luck with this and don’t give up if you have strange errors.
    The five year old GAE plugin for Netbeans still works in NB 8.2

  10. What is the different between App Engine and Compute Engine. Both are a part of Google Cloud infrastucture. I have hosted PHP website on Compute Engine through Cloudways platform. Is compute engine better or app engine?

  11. Hello Ms, a very good tutorial to deploy the Java Web Application to Google App Engine using Netbeans. I face a problem when i deploy the Project where it consists JSP files. I try to resolve the problem by using the following methods:

    1. I add the JDK platform to Java7 and change my project make use of Java7 instead of Java8. I tried to deploy to google app engine and the IDE shows me the error: java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE. Unable to update app: Cannot get the System Java Compiler. Please use a JDK, not a JRE.

    2. I try to change the environment variable to the Java7 jdk on window and deploy again, the IDE shows the same error.

    Can you please guide me on how to solve this problem? I am highly appreciated your help. Thanks!

  12. worked like a charm.
    A few tips.

    Google AE is not accepting Java EE 7 anymore. add these lines to the “appengine-web.xml” file:

    java8
    true

    Regards

Comments are closed.