Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML
 
 
Hot Web Programming Job

 

Tutorial Categories: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML

[an error occurred while processing this directive]

Java Notes

CLASSPATH

[an error occurred while processing this directive]

Do you get the following error message?

Exception in thread "main" java.lang.NoSuchMethodError: main

If so, the following are common causes.

  1. File/class name mismatch. Check the file and class names -- they much match exactly, even with upper and lower case. Windows doesn't care about file names that differ only in case, but Java does. If you have trouble renaming a file to fix the case, first rename it to something different, then rename to the correct case.
  2. Typo in main header. Something is wrong with your declaration of main. It must be
        public static void main(String[] args)
    Slight variations in the parameter declaration are allowed, but the above is by far the most common.
  3. CLASSPATH is explained below in more detail.

CLASSPATH tells Java where to search for programs

Where to look? The Java runtime system needs to know where to find programs that you want to run and libraries that are needed. It knows where the predefined Java packages are, but if you are using additional packages, you must tell specify where they are located.

CLASSPATH. For Windows the easiest way is to set the environment variable CLASSPATH, which Java uses to see where it should find Java programs and libraries.

Automatic? Some IDEs tell the Java runtime system where to search, and double-clickable Jar (Java Archive) files don't have this problem

When do you need it? If you compile "by hand" (typing javac and java in a command window), or sometimes with TextPad or other editors.

Setting CLASSPATH on Windows XP

The CLASSPATH variable can be set on Windows XP with the following steps.
  • Click the Start button in the lower left of the screen.
  • Select Control Panel from the pop-up menu.
  • Choose System from the submenu.
  • Click the Advanced tab.
  • Click the Environment Variables button near the bottom and you will see two lists of variables.
  • Look in the System variables list for a variable named CLASSPATH. If you find it, click Edit. If you don't find it, click New and enter CLASSPATH in the Variable name field.
  • The Variable value field is a list of file paths of directories or jar files. The first thing in this list should be the current directory, which is represented in windows just as it is in Unix, as a single period. If there's more than one thing in this list, separate items with a semicolon. For example, my CLASSPATH variable starts with these three items (there are a couple more, but this should be enough to give you the idea). The only part you need is the first "dot".
        .;C:\classpath\com.fredswartz.ezgui.jar;c:\classpath\TableLayout.jar;
    I put extra libraries that I want to be searched in a directory named classpath, but you can choose any name.

References

A more complete explanation of CLASSPATH can be found in Java Glossary : classpath.

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

0 comments so far (
post your own) View All Comments Latest 10 Comments:
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification

Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.