Java Bean
Java Bean
The jsp:useBean action tag is used to locate or instantiate a bean class. If bean object of the Bean
class is already created, it doesn't create the bean depending on the scope. But if object of bean is
not created, it instantiates the bean.
In this example, we are simply invoking the method of the Bean class.
For the example of setProperty, getProperty and useBean tags, visit next page.
1. package com.javatpoint;
2. public class Calculator{
3.
4. public int cube(int n){return n*n*n;}
5.
6. }
index.jsp file
A JAR file is a Java archive based on the pkzip file format. JAR files are the deployment format
for Java. A JAR can contain Java classes and other resources (icons, property files, etc.) and can
be executable.
You can distribute your program in a jar file or you can use existing java code via jars by putting
them into your classpath.
1.2. Using Java libraries
If you add a JAR file to your classpath, you can use its classes in your Java application.
2. Executable JAR
An executable JAR means the end-user can run the Java application without explicitly specifying
the Java class which should be started. This is done via a MANIFEST.MF file which tells the JVM
among other things which class contains the main() method and the classpath.
Manifest-Version: 1.0
Main-Class: com.vogella.example.MyApp
Class-Path:. lib/jcommon-1.0.6.jar lib/itext-1.4.6.jar
You can create an executable JAR file via the following command.
Eclipse provides an export wizard to create a JAR file which can be started via File → Export →
Java → JAR file