Error when trying to see mvn version in cmd - maven

I keep getting this error when trying to enter "mvn -version in the cmd.
Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/c
lassworlds/launcher/Launcher
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.lau
ncher.Launcher
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.codehaus.plexus.classworlds.launcher.Launcher
. Program will exit.
'cmd' is not recognized as an internal or external command,

This is usually a problem with misconfiguring M2_HOME or M3_HOME. I'm not sure, but I think you can't have both set. Also, do a "which mvn" - apparently some JVM installs will install a mvn in usr/bin.

your maven configure is the problem.
once check your system variables path, MAVEN_HOME AND JAVA_HOME.
IN PATH - %MVN_HOME%/bin and that maven bin path also add in that path.
IN MAVEN_HOME - where your placing the Maven folder that path you add only not bin or lib folders.
IN JAVA_HOME - where you are installed java software that path can place in that directory. This is also not lib or bin folders just only JDK path.
In classpath- you can add just normally lib folder of the maven.
If you are not added the java_home your adding only maven_home that is also some will be raised.
Here i am placing some site url see that one solve your problem.
http://horrikhalid.wordpress.com/2011/01/12/a-simple-tutorial-of-jsf-2-0-eclipse-weld-and-maven-2/
N.S.Reddy

Related

Stanford POStagger demo fails on Windows

I am trying to run the Stanford POSTagger (version 3.6) using the Windows cmd and I am having problems. I am following the instructions in the README with the corrections for Windows.
I have a directory (C:\Program Files\stanford-postagger-full-2015-12-09>)with the POSTagger files.
In the command prompt I am at this directory (..Stanford-postagger-full...).
1)The command: javac -cp stanford-postagger.jar TaggerDemo.java is executed correctly (no error message)
2)The command: java -cp ".;stanford-postagger.jar" TaggerDemo models\wsj-0-18-left3words.tagger sample-input.txt fails. I am getting the following error:
C:\Program Files\stanford-postagger-full-2015-12-09>java -cp
".;stanford-postagger.jar" TaggerDemo
models\wsj-0-18-left3words.tagger sample-input.txt
Exception in thread
"main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at edu.stanford.nlp.io.IOUtils.(IOUtils.java:42)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:765)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.(MaxentTagger.java:298)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.(MaxentTagger.java:263)
at TaggerDemo.main(TaggerDemo.java:20) Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
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)
... 5 more
Any suggestions about my error? Am I at the correct directory to run the commands?
I believe there is another .jar file that you need to add to the classpath. If you look at the error, you'll see that the class that isn't found is org/slf4j/LoggerFactory, which is in .\lib\slf4j.jar.
On a side note, you might want to get a program like 7zip, which allows you a convenient (right-click) method for viewing the contents of .zip and .jar (etc) files. That way, you'll be able to find those classes that you can't find otherwise.
Hope that helps—I'm still new to java.

MissingResourceException: Can't find bundle base name

When running a jar file that i created from a maven project as such:
java -jar basictool.jar
I get this error exception:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.util.MissingResourceException: Can't find bundle for base name com/kit/version, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(UnknownSource)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
at com.factories.FactoryImpl.<init>(FactoryImpl.java:80)
at com.parsers.BasicParser.<init>(BasicParser.java:32)
at com.parsers.FileParser.<init>(FileParser.java:76)
at com.tools.BasicTool.main(BasicTool.java:75)
... 5 more
I created the jar file by using the maven jar creation wizard:
Right-click on project, select Export > Java > Runnable JAR file with options
Launch configuration: BasicTool - work
Export destination: C:\Users\Victor\Documents\basictool.jar
Library handling: Package required libraries into generated JAR
The version.properties file is kept inside of the src/main/resources, as com/kit/version.properties.
I have checked that the version.properties file is found inside of the jar file by running:
jar tf basictool.jar > output.txt
where i find the version.properties file as such:
resources/com/kit/version.properties
I attempt to load the resource like this:
ResourceBundle.getBundle("com/kit/version");
My machine and environment specifications are as followed:
Windows 7, Spring version: 3.7.2.
Note:
I found many questions similar to the one i have, but the answers i have found point to the properties file being properly named or placed in the correct location. From those answers i learned that version.properties is fine, since ResourceBundle.getBundle("com/kit/version") will first look for version.class then version.properties by default. It will also look for version_en_US.properties before ultimately looking for the base name version.properties.
I seem to be in line with the above, since the file version.properties is in the correct location and named correctly. I also seem to be in line with what other answers have offered :(
I would also like to point out that it finds the resource just fine when i run the program from spring, which brings me to suspect that something about the jar's creation process is the cause of the problem.
And it is also important to note that the properties file is in another maven project.
I hope i offered enough/clear details. Any help would be appreciated, thank you in advance!
If your application calls ResourceBundle.getBundle("com/kit/version"); from with in Eclipse everything works fine.
But when you create a jar file in the way you described (export -> java -> runnable jar), the version.properties is placed within the jar file at resources/com/kit/version.properties. Mind the "resources" in front of the path.
If you call this jar with java -jar basictool.jar outside Eclipse the version.properties cannot be found and java.util.MissingResourceExceptionis thrown.
If you change the path and call ResourceBundle.getBundle("resources/com/kit/version"); it won't work within Eclipse but java -jar basictool.jar will do.
It seems exporting the project from Eclipse causes the problem.
I would suggest to create the jar file to use without Eclipse with the maven-assembly-plugin.
An example can be found here.
This plugin creates a jar file without the resources directory and so the call of ResourceBundle.getBundle("com/kit/version"); works within and outside of Eclipse.

Gradle wrapper NoClassDefFoundError

When I run ./gradlew I get
Exception in thread "main" java.lang.NoClassDefFoundError:
org/gradle/wrapper/GradleWrapperMain Caused by:
java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
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:306) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at
java.lang.ClassLoader.loadClass(ClassLoader.java:247)
My project compiles using the Android Studio but stopped compiling from command line
Probably something went bad. The solution:
Install gradle: brew install gradle
Regenerate wrapper: gradle wrapper
See https://github.com/drone/drone/issues/256
My .gitignore had *.jar in it, so I wasn't getting all the jars I needed in my repository.
I had the same, or similar, problem when trying to build my app from command line, but with an exception thrown for 'java.lang.ClassNotFoundException: com.sun.tools.javac.util.Context' which did not happen when building within Android Studio. I found out that AS brings along it's own JRE and I resolved the issue by setting 'JAVA_HOME' to the AS JRE path. In my case it turned into:
$ JAVA_HOME=/opt/android-studio/jre ./gradlew build
You can find this path under 'File' -> 'Project Structure' -> 'SDK Location', see screenshot.
I hit this issue when I have a directory with a ":" (no quotes, just a colon) in it.
This was on a linux machine.
Before:
"my:directory"
as in
/Users/me/projects/project1/my:directory/
then i renamed it to
/Users/me/projects/project1/my_directory/
and the error went away.

How to overcome maven FileNotFoundException error?

I installed maven on usr/share/maven and also have set path in maven.sh file.
i restart my computer and typed
mvn -version
and getting error
java.io.FileNotFoundException: /usr/share/apache-maven/conf/logging
at org.codehaus.plexus.classworlds.launcher.ConfigurationParser.parse(ConfigurationParser.java:264)
at org.codehaus.plexus.classworlds.launcher.Configurator.configure(Configurator.java:133)
at org.codehaus.plexus.classworlds.launcher.Launcher.configure(Launcher.java:131)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[sandip#bigdatasvn ~]$ java.io.FileNotFoundException: /usr/share/apache-maven/conf/logging^C
You need to check the Maven configuration and make sure the logging file is in that path. If you installed on /usr/share/maven, that's also not the same path as /usr/share/apache-maven.
It seems like you are using the epel-apache-maven repo.
(http://repos.fedorapeople.org/repos/dchen/apache-maven/)
If it is the case, do "yum update apache-maven"
and apache-maven-3.2.1-1 should fix the problem.
I'm not saying this will be the solution for everyone, but a restart fixed this problem for me (and #D-Klotz)
Restart eclipse with this command -
eclipse.exe -clean
In case you are using STS (Spring Tool Suite), restart STS with this command -
STS.exe -clean
Hope this will help :)

Trouble installing Kyoto Tycoon - Java. Maven failing

I've downloaded Kyoto Tycoon via:
hxxps://bitbucket.org/EP/kyototycoon-java
When running mvn install I get plenty of warnings telling me it couldn't find several files:
http://pastebin.com/znpJ3d5n
When I first started running the install I was getting a lot of failures and no errors. After blindly going around and trying to install things separately, the output now looks like this. I have no experience with Maven so editing the pom.xml file is out of the question. I've tried using the ignore tests and compiling, and I get few jar files. This allows me to compile "Example.java" using:
javac -cp .:target/kyototycoon-0.2-SNAPSHOT.jar Example.java
I then try to run the code using:
java -cp .:target/kyototycoon-0.2-SNAPSHOT.jar Example
but I get an runtime error:
Exception in thread "main" java.lang.NoClassDefFoundError: Exception in thread "main" java.lang.NoClassDefFoundError: com/twitter/finagle/Codec
at kyototycoon.SimpleKyotoTycoonClient.<init>(SimpleKyotoTycoonClient.java:16)
at Example.main(Example.java:11)
Caused by: java.lang.ClassNotFoundException: com.twitter.finagle.Codec
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)
... 2 more
I'm assuming this all comes back the the maven install failing, but I'm not sure how to fix it.
Any direction is appreciated. There doesn't seem to be a large support group for Kyoto.
For anyone experiencing this same issue, I found that JAR files I needed were being created. They were being stored in ~/.m2/repository/kyototycoon/kytotycoon/. I created a disgusting looking classpath that included all of these JAR files and this allowed me to compile AND run the Example.java file.
If "editing the pom file is out of the question" I'd strongly recommend steering clear of Maven.
In any case, you can install local jars to your repository if the artifact isn't available from any repository.

Resources