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 ...