Category Archives: Java

NoClassDefFound

NoClassDefFound (No Class Definition Found) is a Java Virtual Machine (JVM) error that occurs when a class needed to run a Java program cannot be found. A definite missing class could cause this error, although it is mostly triggered by a faulty CLASSPATH. It may also happen when a Java user adds the unnecessary ‘.class’ extension at the end of a command line, e.g. ‘C:\>java HelloWorld.class’.

During an application server’s shutdown and subsequent redeployment of applications, the user may also see a NoClassDefFound error. When the ClassLoader application turns off before the full shutdown of Coherence, this error usually occurs. When Coherence’s shutdown procedure tries to enter a class definition (whether direct or indirect) this message will be thrown.

A Rational Application Developer plug-in utility can resolve this exception. It can locate Java Archive (JAR) files which contain a certain class for a project’s Java path and help fix NoClassDefFound exceptions.

Definition of Terms

  • Java – a programming language implementation originally developed to compile and complete directive functions regardless of language version and platform. James Gosling for Sun Microsystems created it on June 1991.
  • Java class- a collection of Java variables and methods.
  • Java Virtual Machine – software which enables the recognition and successful execution of Java technology on a wide array of hardware systems, Java virtual machines are termed as such because they offer an environment for Java code execution.
  • CLASSPATH – an environmental variable that informs the Java compiler and JVM of the location of Java class files. In Java 1.2 (and succeeding versions), the variable is less vital because Java can find default classes as well as load these classes from the directory by default.
  • Class – the basis or blueprint for the creation of individual objects.

JRE

JRE stands for Java Runtime Environment. It contains the Java Virtual Machine, libraries and the extra components that run applications and applets written in the Java language. It has two deployments: Java Plug-in and Java Web Start.

Java Plug-In

Java Plug-in, a part of Java SE (Standard Edition), is responsible for running the applets in popular browsers. It builds connections between the browsers and Java platforms. Java Plug-in in its current version is incorporated with a JRE download.

Java Web Start

Java Web Start is the deployment technology that is responsible for setting up independent applications throughout a network. Its framework was developed by Sun Microsystems. It does not operate inside browsers, unlike Java applets. The Java Platform immediately starts from the Internet directly through a web browser.

Java Virtual Machine – The Java Virtual Machine is a piece of software that allows Java to execute on a wide array of platforms. It lays down the essential environment for the Java bytecodes’ execution, while its flexibility permits a Java applet to be written once available.

  • Java Libraries – Java Libraries or a Java Class Library is a set of loadable libraries that Java applications use on runtime. The Java Platform does not depend on a specific OS (operating system); therefore, applications do not depend on existing libraries. The Java Platform, however, provides a set of libraries (standard class libraries) with similar reusable functions found in most modern OS.
  • Java Applets – Applets generally provide features that make web applications interactive. They can substitute HTML in this function. A Java applet is simply an applet delivered in Java bytecode form. Java applets run in Web browsers through a JVM or Java Virtual Machine, and can also be run through Sun’s AppletViewer — an independent tool for applet testing.

Java applets were present during the penetration of Java language in the IT industry in 1995. Later on, they became available in other programming languages that compile to Java bytecode, like Jython.

J2EE

Java 2 Platform Enterprise Edition, now commonly called Java EE, is the general platform name for servers that use the Java Programming Language. The newly developed Java EE is different from its standard edition because it has additional libraries that allow programmers and users to deploy a fault-tolerant, multi-tier, distributed Java Software. This is based on the modular components that run on its application server. J2EE is Sun’s more favored Java application.

Features and Services in J2EE

  1. J2EE supports a pure HTML for additional applets or its applications. It depends on the Java Server Pages and the servlet’s code to create an HTML or produce formatted data for clients.
  2. EJBs or Enterprise JavaBeans give an extra layer where the platform’s logic is stored. The EJB server functions as a concurrency, memory and security management tool, all of which are transparent to an author.
  3. JBDC or Java Database Connectivity in which a Java is equivalent to an Odbc is a standards interface made for Java databases.
  4. A Java Servlet API improves consistency without the need for a graphical user interface.

The J2EE Architecture’s Four Major Elements

  1. The J2EE Applications Programming Model, a standard programming model, is used to facilitate the development of the multi-tier system for thin client applications.
  2. The J2EE Platform includes the necessary policies. Its APIs are similar to Java servlets and the Java Message Service.
  3. The J2EE Compatibility Test Suites ensures that J2EE products are compatible with its platform’s standards.
  4. The J2EE Reference Implementations explain the J2EE’s capabilities and provide operational definitions.

The General APIs in the J2EE

JavaEE APIs include various technologies that extend functionalities based on the Java SE APIs and the J2EE’s other API systems.

  1. Java.ejb –JavaBean’s first and second APIs define a set of APIs allocated to object containers and help give persistence, access control for distributions, concurrency controls, and remote procedure calls.
  2. Javas.transaction
  3. Javax.xtm.stream
  4. Javax.jms Javax.faces.component.html
  5. Javax persistence

For more information on J2EE read:

  • J2EE
  • J2SE

    J2SE or the Java Platform Standard Edition is popularly used in Java language programming. This is the platform commonly used to create portable applications.

    What does J2SE do?

    J2SE consists of a virtual machine needed for a Java program to work together with its set of libraries (packages). These libraries are needed to gain access and use networks, graphical interfaces, file systems and other applications that belong to those programs.

    What are J2SE’s Purpose Packages?

    Descriptions of Main Java SE libraries are as follows:

    1. java.lang – It contains fundamental classes and sets of interfaces narrowly attached to its language and its runtime systems. Included are class hierarchy, math functions, basic exceptions, security functions, threading, and others.
    2. java.lang.ref – It contains a package with more flexible references than others, and allows limited communication between the Java Virtual Machine garbage collector, and its applications.
    3. java.lang-reflect – This reflection is an element of Java API, which allows the code to examine Java’s components during runtime and utilize its reflected elements.
    4. java.io – This package has classes that can support the J2SE’s input and output. These packages are stream-oriented; but random access files are also provided.
    5. java.nio – It is applied to support memory-mapped I/O.
    6. java.math – This helps multiprecision number generators of prime numbers.
    7. java.net – This is an open-source project set.
    8. java.text – This is a package made up of interfaces and classes useful for international localized programs.
    9. java.util – This is a collection of Java utility classes.

    Uses of J2SE

    The J2SE allows users to view Flash movies and hear audio files by simply clicking on a certain page link. As a user clicks, the pages go to the browser environment and begin the process of launching the application. Once the request for access has been granted, the video and sound application is executed. One popular example of J2SE in action is online games. In this type of environment certain facilities coordinate the interaction between the online community and the user via music and video applications.

    Cannot Resolve Symbol

    In the Java programming language, “Cannot resolve symbol” is an error message that tells the user that the Java compiler cannot locate a symbol referenced in the source code. This common error prevents Java programs from running properly.

    The following often cause “Cannot resolve symbol”:

    1. Class files needed by the compiler and the source code may be missing. This normally happens when a particular class file becomes corrupted or is removed or renamed.
    2. A CLASSPATH may be faulty. A CLASSPATH is an environment variable that provides information to the compiler regarding the location of class files. When this variable is not working, the compiler will not be able to identify the symbol although it may in fact be present.
    3. A symbol name may be capitalized or spelled incorrectly. When writing codes for large programs or when trying to beat a deadline, individuals tend to type hastily. As a result, they do not notice that they sometimes type symbol names incorrectly. If this happens, the compiler would be unable to match the symbol in the source code with those in the class files.

    There are other less common causes of the “Cannot resolve symbol” error. These include a variable, which was not declared, and a method called with the incorrect types of arguments.

    Writing the codes carefully is the best way to prevent the said errors. Java programmers should always check their blocks of code and look for the possible mistakes mentioned above.

    Constructor

    A constructor refers to a special method used to initialize a new instance of a specific class. Since it is a method, a constructor includes a set of associated statements created to perform a general function. Constructors are part of a class; therefore, they interact with variables to carry out their tasks.

    In most programming languages, a constructor for a certain class must have the same name as the class. This rule is implemented to ensure that the system knows all the classes and their corresponding constructors, and that errors will not be encountered during the execution of the source codes.

    In certain languages, if the user does not create a constructor for a particular class, the system would automatically create one for it. This type of constructor is public and does not accept any parameters. Its main purpose is to call the classes that the current class inherits from, which are also called base classes.

    Multiple constructors may be included in a class. In the event of a class having two or more constructors, these constructors will have the same name. The class will be able to distinguish one constructor from the other through its arguments. This is because all constructors handle unique arguments. Still, there are constructors which do not take any arguments. These are aptly called non-argument constructors.

    Constructors are incorporated in many programming languages. JAVA and C# are two of the most common languages that use constructors in their source codes.

    Java Constant

    Java is a programming language used to create programs that can run on a variety of Operating Systems. A Java constant is a variable with a pre-defined value. Although Java does not have a constant type, you can effectively obtain the same effect with a final variable. This enables you to have a control of what is constant and what is not.

    You can have a constant effect by declaring and initializing public, static, and final variables. The static modifier makes the variable obtainable without loading an occurrence of the class where it is defined.

    Once you have initialized the constant variables, their value cannot be changed anymore. After initializing, you can gain access to the constant value with the variable’s name and the name of its class with a period.

    An Example of Java Constant

    An example of a constant variable is the speed of sound in air at 0°C. This value does not change. If you want to make use of the value in a program, you should set this value as a constant:

    final double SPEED_OF_SOUND_IN_AIR = 331.5;

    In the example given, the “final” modifier is the indicator that makes SPEED_OF_ SOUND_IN_AIR constant and fixed.

    Standard Naming Convention

    In declaring Java constant variables, you should declare the variable names in ALL CAPS (notice each letter of the variable name above). The words in Java constants are typically separated with underscores (as in the example above). This format indicates that these values are constants. It will be easier for an individual to read a code if this standard naming convention is followed.

    Enumerated Constants in Java

    Enumerable constants are often arranged in a specific way. Constants are characters or symbols with definite value, such as numbers.

    An array of enumerable constants can be used as the index variable in a Java for loop. They can also be used to file an array. In Java, enumerable constants are well-recognized as enumerated constants. Using this set of constants can make the code more readable.

    In languages like Pascal, one essential quality of enumerated constants is that they are type-safe. This attribute lacks static final integers.

    Java for Vista

    Java is a software platform that provides resources for a number of programs. It allows applications to run on a number of Operating Systems. Java is also used in mobile phones and handheld devices. Users may encounter Java applets or plug-ins necessary to view some programs published on the World Wide Web.

    Many applications and online games need a Java platform to run. However, it does not come pre-installed with Windows Vista. You will need to install and activate the latest version of Java for Windows Vista before you can run the programs. The software is free and readily available.

    To download the latest version of Java:

    1. Visit the official Java website and find the latest version. Check Java’s system requirements and see if you have enough memory space available.
    2. Verify if your computer already has a Java installed. Click “Do I Have Java?” and then “Verify Installation.”
    3. Go to “All Java Downloads.” Pick the Java for Windows Vista and decide whether you want an online or offline version. (The offline version consumes roughly 6 additional megabytes compared to the online version of the hard drive.
    4. Hit the “Start Download” button. If a security warning appears, let the Web browser allow the installation of the ActiveX control.
    5. If prompted, reset your computer. This is for the Java installation to take effect.

    To activate Java:

    1. Open the Internet Explorer Web surfer. Click “Tools,” located on the upper right potion of the page.
    2. Go to “Internet Options.” It can be identified through the icon that looks like a cup of coffee.
    3. Click the “Advanced” tab.
    4. Find the “Java” section in the Settings list. (If you can’t find the Java section, Java is most likely not installed correctly.)
    5. Once you have located the “Java” section, click on the option under Java to enable the software. Then, click OK.
    6. Uncheck the option to disable Java.

    Once installed, you can now visit websites requiring a Java platform in their design. The software will be activated automatically. Once Java is installed, it will automatically check for updates and prompt the user when there is one available.

    To uninstall Java:

    1. Click the Start button of Windows.
    2. Go to Control Panel and proceed to “Uninstall or Change Program.”
    3. Look for Java in the roster of programs. Hit the “Remove” button.

    Java software is used to make and present animated Web content. It can be employed for many different purposes, including animated videos and other programs.