I was trying to install the PMD plugin to my IntelliJ IDE. I have followed the instructions but when trying to run the pmd check I am getting the following exception. From what it seems the “.” Is being parsed as a / which produce a wrong file name for the class loader.
Meaning the path: Even though the settings are
-cp %CLASSPATH%; C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4.2.5.jar; C:\Development\IDE\Utils\PMDPlugin\lib\asm-3.1.jar; C:\Development\IDE\Utils\PMDPlugin\lib\jaxen-1.1.1.jar net.sourceforge.pmd.PMD "$FilePath$" ideaj unusedcode,imports "$Sourcepath$" $FileClass$.method $FileName$
From some reason it is still looking for C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4/2/5/jar
Here is the exception:
java.lang.NoClassDefFoundError: C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4/2/5/jar;
Caused by: java.lang.ClassNotFoundException: C:.Development.IDE.Utils.PMDPlugin.lib.pmd-4.2.5.jar;
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: C:/Development/IDE/Utils/PMDPlugin/lib/pmd-4.2.5.jar;. Program will exit.
Exception in thread "main"
I am using Intelli IDEA 10.0.3
Build #IC 103.288 built on April 2011
JDK 1.6.0_21
Do you have any advices?? Thanks
Looks like you have spaces between your CLASSPATH entries. That won't do; remove them.
UPDATE:
I downloaded PMD and managed to make it run. I followed the directions that you posted, replacing the path to PMD with my own. I'd recommend not using a path that has spaces in it.
The one thing that was balky was %JAVA_HOME%, so I replaced it with the hard-wired path to my Java /bin. Once I did that, all was well.
I'd ask why you think PMD is better than the inspector tools built into IntelliJ? I'd rather check boxes to set rules than have to do all the nonsense that PMD requires.
Once I was satisfied that I could make it work I deleted it. I'd rather run Inspector.
Related
Using Intellij 15.0.3 on a Scala project, I am unable to run my scala console.
I added one too many dependencies and Intellij told me "Command line is too long. In order to reduce its length classpath file can be used.Would you like to enable classpath file mode for all run configurations of your project?" I enabled it, whihc sets dynamic.classpath=true in an xml file.
Now when I try to run the console I get
Exception in thread "main" java.lang.ClassNotFoundException: #vm_params
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.intellij.rt.execution.CommandLineWrapper.loadMainClassWithOldCustomLoader(CommandLineWrapper.java:174)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:38)
Googling around I didn't see anyone else have this problem. This feature seems like it should "just work". Is there something else I have to do do get intellij to make a classpath file and send the path to the VM?
I did found quite a lot about this error, but somehow none of the suggested solutions resolved the problem.
I am trying to use JNA bindings for libgphoto2 under Ubuntu in Eclipse (moderate experience with Java on Eclipse, none whatsoever on Ubuntu, I'm afraid). The bindings in question I want to use are here:
http://angryelectron.com/projects/libgphoto2-jna/
I followed the steps described on that page, and made a simple test client that failed with the above error. So I reduced the test client until the only thing I tried to do was to instantiate a GPhoto2 object, which still produced the error. The test client looks like this:
import com.angryelectron.gphoto2.*;
public class test_class
{
public static void main(String[] args)
{
GPhoto2 cam = new GPhoto2();
}
}
The errors I get take up considerably more space:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/jna/Structure
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at test_class.main(test_class.java:12)
Caused by: java.lang.ClassNotFoundException: com.sun.jna.Structure
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
libgphoto2 itself is installed, it runs from the command line, I even have the development headers and am able to call GPhoto2 functions from python, so the problem can't be located there.
When looking at the .class files in Eclipse, however, they didn't have any definitions. So I figured that might be the problem, especially since there was an error when building the whole thing with ant (although the .jar was succesfully exported, from what I could make out the error concerned only the generation of documentation).
So I loaded the source into eclipse and built the .jar myself. At this occasion Eclipse stated there were warnings during the build (though no errors), but didn't show me the actual warnings. If anyone could tell me where the hell the build log went, that might already help something. I searched for it everywhere without success, and if I click on "details" in eclipse it merely tells me where the warnings occured, not what they were.
Be that as it may, a warning isn't necessarily devastating, so I imported the resulting Jar into the above client. I checked the .class files, this time they contained all the code. But I still get the exact same list of errors (yes, I have made very sure that the old library was removed from the classpath and the new ones added. I repeated the process several times, just in case).
Since I don't have experience with building jars, I made a small helloworld jar, just to see if I could call that from another program or if I'd be getting similar errors. It worked without a hitch. I even tried to reproduce the problem deliberately by exporting it with various options, but it still worked. I tried re-exporting the library I actully need with the settings that had worked during my experiment, but they still wouldn't run. I'm pretty much stuck by now. Any hints that help me resolve the problem would be greatly appreciated.
In addition to what #Paul Whelan has said. You might have better luck by just get the missing jar directly.
Get the missing library here, set the classpath and then re-run the application again and see whether it will run fine or not.
What version of java are you using com/sun/jna/Structure may only work with certain JVMs.
In general, packages such as sun., that are outside of the Java platform, can be different across OS platforms (Solaris, Windows, Linux, Macintosh, etc.) and can change at any time without notice with SDK versions (1.2, 1.2.1, 1.2.3, etc). Programs that contain direct calls to the sun. packages are not 100% Pure Java.
More details here
Your jar needs a MANIFEST.MF which tells your application where the library is found. Create the file in you project root-directory in eclipse and add the following lines:
Manifest-Version: 1.0
Class-Path: <PATH_TO_LIB__CAN_BE_RELATIVE>.jar // e.g Class-Path: ../test.jar
<empty line>
Right-click your project in eclipse, go to Export->next->next->next->Use existing manifest from workspace, select it and click on finish. This should work.
Another solution is to compile the classes into the jar itself with Maven.
I'm still very new to Java. I'm trying to use CMU's Sphinx4 voice recognition. When I used the compiling process they have prepared, everything worked fine. However, now that I'm trying to compile my own code separately I'm running into a problem.
In the codes source files (src/) exists an apps/ directory which contains the demos I'm trying to compile manually, along with a sphinx4/ directory which contains the main functions to be used. To compile the code I move into the apps/ directory and run
javac -classpath ../sphinx4/ edu/cmu/sphinx/demo/helloworld/HelloWorld.java. This compiles without error. However, then when I try to run the newly made class using java edu/cmu/sphinx/demo/helloworld/HelloWorld the result is:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/cmu/sphinx/util/props/ConfigurationManager
at edu.cmu.sphinx.demo.helloworld.HelloWorld.main(HelloWorld.java:33)
Caused by: java.lang.ClassNotFoundException: edu.cmu.sphinx.util.props.ConfigurationManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 1 more
Yet, as far as I can tell, the class does exist right where it should be. src/sphinx4/edu/cmu/sphinx/util/props/ConfigurationManager.class exists. I'm guessing there is a good reason that it is considered not found when it is there, but I just don't know it because I don't know enough about Java yet. What might cause this to happen?
Thank you for your time!
Two problems:
You need to specify the classpath when you run as well as when you compile
You need to specify a class name to run; that won't have slashes in
You want:
java -classpath .:../sphinx4 edu.cmu.sphinx.demo.helloworld.HelloWorld
Use ";" instead of ":" if you're running on Windows.
(Your error message suggests that you actually are giving the right class name, in which case your question hasn't really shown what you're doing. It's important to be accurate in your question, in order to get helpful answers.)
Look:
Note 4:
If you have the source distribution, make sure that the JAR file lib/sphinx4.jar is built. If not, go to the top level directory and type: ant.
You should probably use ant to build the project with your new class(es).
Did you follow the instructions here: http://cmusphinx.sourceforge.net/sphinx4/#how_build ?
Good luck!
I am trying to run Tomcat 6.0.18 from Netbeans 6.7 but getting the following output
on the server console.
java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:54)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
I have tried reinstalling , tried different versions of tomcat viz. 6.0.24 , 7.0.16 , 5.5 etc , shifted from eclipse to netbeans to but don't why it is coming. In one of the replies for the same it was suggested to add $CATALINA_HOME\bin\tomcat-juli.jar to the launch configuraton in case of eclipse but in netbeans this library along with the others in lib folder have already been added. still the situation is same :(
try this , it has solved the problem
it seems that the META-INF/MANIFEST.MF file in the bootstrap.jar contains a no reference for
tomcat-juli.jar
just add/update this entry in META-INF/MANIFEST.MF file in the bootstrap.jar
Class-Path: commons-daemon.jar tomcat-juli.jar
and then try to run the tomcat sever
Hi,I have just begun to learn, also encountered the same problem, and finally I get through the following steps:
Tomcat v7.0 Apache Open,
Information Overview in General launch
Open configuration >Edit >Configuration, >Classpath, >Entries,
External TOMCAT_HOME/bin/tomcat-juli.jar
restart your lomboz
For more information,you can view this picture,hope this will fix your problems.
For some reason, the tomcat-juli.jar (or whichever JAR contains org.apache.juli.logging.LogFactory) isn't added to the classpath.
You don't say how you start tomcat (Eclipse Tomcat plugin, Web Tools, ANT script, ...) so it's hard to say why it's not there. If you can, add a breakpoint in URLClassLoader.java:202 and examine the result of calling getURLs() (see point #5 in 5 Tips for Debugging Java Code in Eclipse).
Bootstrap.jar is missing that is why this Exception is coming
I run my software through Eclipse. Yesterday everything was fine. I made not changes to the code but today, when I am trying to run it again I get the following error messages:
Exception in thread "main" java.lang.NoClassDefFoundError: coloredtrails/CTListener
at test.DemoPlayer1.createAndShowGUI(DemoPlayer1.java:23)
at test.DemoPlayer1.main(DemoPlayer1.java:39)
Caused by: java.lang.ClassNotFoundException: coloredtrails.CTListener
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Why it does not see the class? What could be the reason of that? How can I resolve the problem?
A NoClassDefFoundError (almost) always means that your classpath is wrong. Make sure that your classpath includes the base directory of the coloredtrails package. (Ofcourse, also make sure that the file coloredtrails\CTListener.class actually exists).
When running from the command line:
You can set the classpath by setting the CLASSPATH environment variable, or by specifying it with the -cp or -classpath option on the command line when you run your program. For example:
java -cp C:\MyProject\classes coloredtrails.CTListener
edit - Looking at the stack trace and seeing URLClassLoader in there makes me think that you are trying to run a Java applet. To learn how to correctly deploy applets, so that all classes the applet needs can be found, see this tutorial: Deploying an Applet.
Sometimes, my Eclipse (Indigo on MacOSX) does that, expecially if I do changes (removing files, moving them around) to the project structure on the filsystem directly.
Basically, eclipse cannot find the source folder anymore, so he doesn't compile the source but tries to run it anyway (all this without a warning or a reference to the problem).
To fix it, remove the source folder from the build path (=right click on the src folder under the project in the package explorer, then choose "Build-path->Remove from Build-path". Then, add it again (=right click on the folder under the project in the package explorer and choose "Add to build-path"). This makes the src folder "visible" to the compiler again and fixes the problem.