Many CLASSE users and groups are using the NetBeans IDE and Payara Application Server for developing and deploying java applications.
"payara.classe.cornell.edu" is a production payara server, with payara-dev.classe.cornell.edu serving as a development server.
Differences between GlassFish
and Payara: https://blog.payara.fish/are-glassfish-and-payara-server-the-same
- As of 2021, Payara can run on Java 8, 9, or 11; Java 11 is recommended
- Install and launch Apache Netbeans, or from a CLASSE Linux computer start the NetBeans IDE using /nfs/opt/netbeans/bin/netbeans
- Click on "New Project," and select "Java with Gradle"
- name and complete the setup of your project as desired.
- click on
- right-click on
Servers and choose
Add Server ...
- Select a server location, and choose "Local Domain"
- Download, and complete the setup of your Payara server
If you require a MySQL database for your application, submit a ServiceRequest
describing what you would like to use the database for. Please see JDBCResourcesInGlassFish
for instructions on configuring NetBeans / Payara for use with a database.
Cornell's Computer Science Department has an introductory database course, CS 4320/5320, that covers the basics for understanding relational databases. It does touch on some underlying mathematical priniciples, but it aims to initially provide the building blocks needed to use relational databases. For example, it covers how to create tables and then link them with primary and foreign keys.
As of Fall 2018, the entire set of Fall 2017 lectures for this course is available on Cornell's Video On Demand site
The first three or four lectures cover the essentials required for setting up and using a relational database. They'll introduce you to tables, columns, rows, primary keys, and foreign keys. Databases have other more complex features, but those are the main building blocks needed to create and use a relational database.
Once you are ready for others to view and test your application, please submit a ServiceRequest
for instructions on where to deploy your application on our centrally available payara servers.
Note: this whole section should be moved to a page that is specifically for Java EE development. This doesn't have anything to do with Payara or Glassfish.
Adhering to the following guidelines will help ensure your code is developed in a manner consistent with the rest of CLASSE's java web applications.
- Use ApacheNetBeans as the IDE.
- Keep a model-view-controller approach.
- the ApacheNetBeans auto-generator helps to maintain this approach
- Entity and Facade classes handle the model
- Controller classes handle the controller
- XHTML pages handle the view
- The following tutorials may be helpful when just starting out. https://netbeans.org/kb/trails/java-ee.html
- This tutorial requires access to a MySQL database. Please request a test database from email@example.com if you are developing on a LEPP Linux machine. Alternatively if you are developing on a personally-owned computer, you also have the option of installing the MySQL database on your personal computer.
- Use Java Server Faces 2.x (JSF) for the web interface.
- Use PrimeFaces an open-source JSF framework for added functionality.
- Use OmniFaces JSF 2 utility for added functionality (Primefaces will probably be enough; you can wait to add Omnifaces as the need arises)
- Oracle’s Java EE 7 Tutorial - this can explain all of the annotations you see in the code, as well as anything else related to Java EE. This is the official Java EE document.
using ViewScoped instead of SessionScoped
One other note I’ll add about the app you’re creating is that while it is nice that NetBeans creates those CRUD pages for you, they’re a bit dated and aren’t really doing things the “right” way. In particular the “backing beans” (i.e. the controller classes) are all Session Scoped. The upside is that what they create works. The downside is doing it the “right” way means basically abandoning the XHTML and controller classes they create for you.
If you look at the controllers in the other busoff and chess inventory projects you’ll see that controllers are View Scoped by the @ViewScoped annotation (note the import name for viewscoped should be javax.faces.view.ViewScoped; there are actually two possibilities for this name, and the other one won’t work!). This annotation means that every time a page that uses that backing bean is called a fresh instance of that controller object will be created. If you noticed, there is no place in the code where objects of those classes are constructed. The annotation tells the Payara container to do the constructing, which is how the XHTML pages can access them.
To oversimplify a bit, I’ll just say using @ViewScoped ensures you are going to see what you are expecting to see (viewing a piece of equipment, an inventory item, etc.). With session scoped backing beans, in effect pages appear to get cached in the browser, requiring users to reload pages in order to see changes they’ve made to the database, etc. Basically, the only classes that should be session scoped are classes that deal with users as the session scope covers the time between the user visiting the site to the user quitting the browser or 30 minutes, whichever comes first (see the session-timeout tag in web.xml).
If you Google questions about JSF and Java EE, you will likely come across answers written by Bauke Scholtz (aka BalusC
) on StackOverflow. He is a JSF expert and has written a book about it, called The Definitive Guide to JSF in Java EE 8: Building Web Applications with JavaServer Faces
. If you see he answered the question, you can trust his answer is correct and authorative. You can also go directly to his StackOverflow page where he provides introductory JSF information.
The JSF book is available as a free download from Springer Link, if you access the URL from a Cornell network: https://link.springer.com/book/10.1007/978-1-4842-3387-0
(last accessed: 12/17/18).
CESR Java Development Documenation
CESR maintains their own NetBeans release and documentation. While aspects of their documentation is CESR specific, this could be a great resource for anyone just getting started with NetBeans or Java development.