Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Hands-On Artificial Intelligence with Java for Beginners
  • Table Of Contents Toc
Hands-On Artificial Intelligence with Java for Beginners

Hands-On Artificial Intelligence with Java for Beginners

By : Nisheeth Joshi
1.3 (3)
close
close
Hands-On Artificial Intelligence with Java for Beginners

Hands-On Artificial Intelligence with Java for Beginners

1.3 (3)
By: Nisheeth Joshi

Overview of this book

Artificial intelligence (AI) is increasingly in demand as well as relevant in the modern world, where everything is driven by technology and data. AI can be used for automating systems or processes to carry out complex tasks and functions in order to achieve optimal performance and productivity. Hands-On Artificial Intelligence with Java for Beginners begins by introducing you to AI concepts and algorithms. You will learn about various Java-based libraries and frameworks that can be used in implementing AI to build smart applications. In addition to this, the book teaches you how to implement easy to complex AI tasks, such as genetic programming, heuristic searches, reinforcement learning, neural networks, and segmentation, all with a practical approach. By the end of this book, you will not only have a solid grasp of AI concepts, but you'll also be able to build your own smart applications for multiple domains.
Table of Contents (9 chapters)
close
close

Importing Java libraries and exporting code in projects as a JAR file

We will now download a JAR file from the internet and use it in our project to create a JAR file for our project.

Open a web browser and search for download a junit.jar. This will take you to a link where you can download a JAR file. There are online repositories available where JAR files exist. One of the most reliable repositories can be found at http://www.java2s.com/Code/Jar/j/Downloadjunitjar.htm, where you can download any available JAR file. If you click on it, it should take you to the following page:

As seen in the preceding screenshot, you will find the junit.jar file and the different classes that are available in the JAR file also listed. You can right-click on the save (floppy disc) symbol to save the file on your system.

Once the file is downloaded, extract it into a junit.jar file. You can then add it to your project with the following steps:

  1. Create a new project on NetBeans, for example, HelloWorld.
  2. Since the new project will not have the junit.jar file, go to Properties by right-clicking on the project, as shown in the following screenshot:

  1. Go to the Libraries | Add JAR/Folder option and provide the location of where this junit.jar file is, as follows:

  1. Once done, click on Open and it will be added to your project:

  1. Now the JAR file has been added to the project, we can use the junit.jar file in an import statement. We can also import individual packages, as shown in the following screenshot:

  1. If you want to use all of the classes in framework, you just have to write the following code:
import junit.framework.*;
  1. Now, let's use the following code to print the output Hello World:
package helloworld;

/**
*
* @author admin
*/
import junit.framework.*;
public class HelloWorld {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("Hello World");
}
}
  1. After running the preceding code, you should get an output similar to the following:

If you want to create a JAR file for this project, please perform the following steps:

  1. Go to Run and select Clean and Build Project (HelloWorld) to build your project:

  1. Once building the HelloWorld project is complete, the Output window will say BUILD SUCCESSFUL, as shown in the following screenshot:

  1. To check if the JAR file been created or not, go to Windows Explorer and navigate to your project's location, which you received from the previous output:

  1. Open the project folder, in our case HelloWorld, and go into the dist folder, as follows:

  1. In the dist folder, you will find the JAR file (HelloWorld.jar), which you can use and where there will be a lib folder. This will contain the junit.jar file that is being used by the HelloWorld.jar file:

This means that whenever you use any JAR files in your project, they will be stored in the lib folder of your JAR file.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Hands-On Artificial Intelligence with Java for Beginners
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon