There was a problem with the Java program running: Could not find the main Class:test_jena. Program would exit.

Source: Internet
Author: User
generally this problem is due to the careless running the program to compile the generated file name incorrectly, but this time is not.
Java programs can compile through, but there are problems at run time:
Exception in thread "main" Java.lang.NoClassDefFoundError:test_jena
caused by:java.lang.ClassNotFoundException: Test_jena at
	java.net.urlclassloader$1.run (urlclassloader.java:217)
	at Java.security.AccessController.doPrivileged (Native method) at
	Java.net.URLClassLoader.findClass ( urlclassloader.java:205) at
	Java.lang.ClassLoader.loadClass (classloader.java:321) at
	sun.misc.launcher$ Appclassloader.loadclass (launcher.java:294) at
	java.lang.ClassLoader.loadClass (classloader.java:266)
	At Java.lang.ClassLoader.loadClassInternal (classloader.java:334) could isn't find the
main Class:test_jena. Program would exit.
There are no problems with the Java program, and there is no problem with JRE and JDK installations. Recall that I directly used the export of a new Classpath:export classpath=/home/liaomeng/apache-jena-2.7.4/lib. Try to delete this classpath variable, found that the program can be normal to compile and run ... So guess the reason for this problem is: This classpath covers the original system default CLASSPATH variable value (originally installed Java with the Yum installation, Java should use the default classpath path)
After careful examination found that the general add Classpath are ".:" Beginning, should not add it, try, and sure enough ... So, change the order to Export classpath=.:/ Home/liaomeng/apache-jena-2.7.4/libcan solve the problem.
Summary: Use export to add classpath must be preceded by ".:", multiple jar packages separated by ";" The test found that the path variable can also be added through the Export command, but must be added after the existing PATH variable, so must: Export path= $PATH:/home/lm/apache-jena-2.7.4/bin,        The newly added PATH variable does not replace the PATH variable before the system. If you are not using export to add environment variables, modify/etc/profile or. bashrc files, you need to carefully fill in each variable and path, carefully sailing ship ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.