Posts

Showing posts from March, 2017

NetBeans For Java How To Install and Get Started with Java Programming (on Windows)

NetBeans (@ http://netbeans.org ) is an open-source Integrated Development Environment (IDE). NetBeans began in 1996 as a Java IDE student project at Charles University in Prague. Sun Microsystems acquired NetBeans in 1999. In 2010, Oracle acquired Sun (and thus NetBeans). Compared with its rival Eclipse ( http://www.elicpse.org ) (both are open-source, so I don't know what are they competing for?), NetBeans provides seamless support for Java AWT/Swing, Java ME mobility pack, Java EE, and bundled with an excellent profiler for performance tuning. How to Install NetBeans 8.2 Step 0: Install JDK To use NetBeans for Java programming, you need to first install Java Development Kit (JDK). See " JDK - How to Install ". Step 1: Download Download "NetBeans IDE" installer from http://netbeans.org/downloads/index.html . There are many "bundles" available. For beginners, choose the 1st entry "Java SE" (e.g., " netbeans-8.2-javase-windows.exe ...

Example to connect to the mysql database in java

For connecting java application with the mysql database, you need to follow 5 steps to perform database connectivity. In this example we are using MySql as the database. So we need to know following informations for the mysql database: Driver class: The driver class for the mysql database is com.mysql.jdbc.Driver . Connection URL: The connection URL for the mysql database is jdbc:mysql://localhost:3306/sonoo where jdbc is the API, mysql is the database, localhost is the server name on which mysql is running, we may also use IP address, 3306 is the port number and sonoo is the database name. We may use any database, in such case, you need to replace the sonoo with your database name. Username: The default username for the mysql database is root . Password: Password is given by the user at the time of installing the mysql database. In this example, we are going to use root as the password. Let's first create a table in the mysql database, but before creating table, we need t...

Why Magic numbers are bad? [JAVA TIP]

Hey guys, today I'd like to share a tip about "How to avoid magic numbers in your code". Let's look at the first code snippet: float getScaledPageWidth(float zoomRation) { return zoomRation * 210; } And here is the updated version: static final float A4_PAGE_WIDTH = 210;   float getScaledPageWidth(float zoomRation) { return zoomRation * A4_PAGE_WIDTH; } Do you know what the differences? Can you guess what was improved? And remember to share with your friends if you want them know tip too. I bet they will be thankful you.