I couldnt understand what is causing this error:
ERROR>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
ERROR>Caused by: java.lang.ClassNotFoundException: org.apache.log4j.PropertyConfigurator
Already got the log4j-1.2.8.jar everywhere in the project but I couldnt make it. How can I make this error go away? Thanks!
Well, you haven't said what kind of application this is or basically given us any context. You need to make sure that the log4j classes are available to the classloader which is loading your application. If it's a standalone application run from the commandline, that's like to just be a case of specifying the -classpath command-line option. For example:
java -classpath .;log4j-1.2.8.jar org.foo.MyApplication
If you can give us more information, we're likely to be able to help you more.
Setp 1 : right click on your main method
Step 2 go to run as option then
Step 3 go to Run configuration
Step 4: and add projects or jar files
now it works.
Related
I get this message in the console when trying to run a basic program.
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/edge/EdgeDriver
In the picture it clearly shows that i have the class available in my referenced libraries but it is not being picked up during execution.
Picture of Eclipse window
Well, I did some test and reproduced the problem. Something like this.
The cause of the problem might be this: You added the jar packages to the modulepath instead of the classpath. Just adding them to the classpath fixes this issue:
I am facing the below error.
"Error: Could not find or load main class weblogic.server" in eclipse.
I am using eclipse luna & weblogic server 10.0.3 for my application.
The inbuilt script setWLSEnv.sh (C:\Oracle\Middleware\wlserver_10.3\server\bin) is setting a different classpath. The below path is not there in my desktop.
CLASSPATH="C:\Oracle\MIDDLE~1\patch_wls1036\profiles\default\sys_manifest_classpath\weblogic_patch.jar
I guess that is why it is not able to find the class.
How can I set correct classpath of this.
Tried searching to set classpath in weblogic admin console. but not able to find it.
Any help will be really appreciated!!.. Thank you in advance.
When execute setWLSEnv.sh the command must be: ". ./setWLSEnv.sh" instead of "./setWLSEnv.sh" (there are 2 seperate dot). Then you should be fine doing next step
The first screenshot shows a working run configuration. The second shows a non working one. They are identical module/classpath wise - at least according to the visible info.
Clearly there's a bug in IJ for this. So .. how have others of you out there discovered a workaround for this? Also, ideas on what triggers this behavior?
WORKING run configuration
NOT Working run configuration - gives ClassNotFoundException for org.apache.hadoop.fs.PathFilter
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.fs.PathFilter
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
Here is the UDFPafDqm module - which DOES include hadoop jar from Hortonworks - so the ClassNotFoundException is bogus
The process above was repeatable : if you copy a run configuration it does not necessarily work - and can fail as described. You have to start from scratch. This is an IJ bug.
I am trying to run an open-source program called LinkedIn Norbert (https://github.com/linkedin/norbert) in Scala 2.8.1. I have added all the jar files so the program compiles, but when I try to run class com.linkedin.norbert.javacompat.network.RunNorbertSetup in examples/src/main/java, I get the following error:
Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.augmentString(Ljava/lang/String;)Lscala/collection/immutable/StringOps;
at com.linkedin.norbert.jmx.JMX$.name(JMX.scala:59)
at com.linkedin.norbert.cluster.ClusterClient$$anon$1.<init>(ClusterClient.scala:56)
at com.linkedin.norbert.cluster.ClusterClient$class.$init$(ClusterClient.scala:55)
at com.linkedin.norbert.cluster.zookeeper.ZooKeeperClusterClient.<init>(ZooKeeperClusterClient.scala:22)
at com.linkedin.norbert.cluster.ClusterClient$.apply(ClusterClient.scala:33)
at com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient.<init>(ZooKeeperClusterClient.scala:23)
at com.linkedin.norbert.javacompat.cluster.ZooKeeperClusterClient.<init>(ZooKeeperClusterClient.scala:21)
at com.linkedin.norbert.javacompat.network.RunNorbertSetup.configCluster(RunNorbertSetup.java:115)
at com.linkedin.norbert.javacompat.network.RunNorbertSetup.main(RunNorbertSetup.java:21)
What would I need to do to get past this error? I've looked at other Stack Overflow and forum threads, and these have not helped.
FYI: I built the program with SBT.
Thanks so much,
Rebecca
Run a "clean" instead of build. Remove all the build and bin folders from the project directory too.
The solution was to put the relevant class in the classpath.
I am completely new to Java, just learned a little because I need to run this project: https://github.com/ansjsun/ansj_seg
I have run
mvn compile
and some other stuff.
Now, in ansj_seg/target I have a file named ansj_seg-0.8.jar, which seems important, although I don't know how to use it.
In ansj_seg/src/test/java/org/ansj/demo, there are some demos, and I want to run BaseAnalysisDemo.java, I tried as following.
Step one, I compile using:
javac -classpath ~/Downloads/ansj_seg/target/ansj_seg-0.8.jar BaseAnalysisDemo.java
It works fine and generates BaseAnalysisDemo.class.
But when I try to run it using
java BaseAnalysisDemo
An error occurs:
Exception in thread "main" java.lang.NoClassDefFoundError: BaseAnalysisDemo (wrong name: org/ansj/demo/BaseAnalysisDemo)
I guess I should set some path, but have no idea.
Anyone can help?
BTW, I prefer using command line to Eclipse.
The directory structure is like this(Updated):
\ansj_seg
pom.xml
\src
\main
\java
\org
\ansj
\app
\dic
\domain
...
\resource
...
\test
\java
\org
\ansj
\demo
BaseAnalysisDemo.java
Demo.java
...
\test
...
Here is another question, even if the demo can be run, how can I use this java library in another place? I guess the file ansj_set-0.8.jar should be used. Again, I know nothing about Java.. Any suggestion will be very helpful.
Updated:
If I run with classpath specified:
java -classpath ~/Downloads/ansj_seg/target/ansj_seg-0.8.jar BaseAnalysisDemo
still got an error, but different:
Exception in thread "main" java.lang.NoClassDefFoundError: BaseAnalysisDemo
You will fall back to Eclipse soon, because what you'd like to do is a bit cumbersome, but doable.
Try this:
mvn exec:java -Dexec.mainClass="java.org.ansj.demo.BaseAnalysisDemo.java"
If you need arguments too, add -Dexec.args to the list.
Note that you'll have to move your demo under the main source tree.