Oracle SqlDeveloper JDK path - java

I have recently installed sqldeveloper but i'm getting the below warning window when I try to launch it. This is causing the sqldeveloper to run very very slow and it hangs frequently
I have tried editing the file sqldeveloper.cong as suggested in the window above but does not work
Original
SetJavaHome ../../jdk
Update 1
SetJavaHome C:\Program Files\Java\jdk1.7.0_60\bin\ and all other variations but still getting the above warning window
Update 2
SetJavaHome C:\Program Files (x86)\Java\jre7\bin and all other variations
Please suggest the correct way

The message seems to be out of date. In version 4 that setting exists in two files, and you need to change it in the other one, which is:
%APPDATA%\sqldeveloper\1.0.0.0.0\product.conf
Which you might need to expand to your actual APPDATA, which will be something like C:\Users\cprasad\AppData\Roaming. In that file you will see the SetJavaHome is currently going to be set to the path to your Java 1.8 location, so change that as you did in the sqldeveloper.conf:
SetJavaHome C:\Program Files\Java\jdk1.7.0_60\bin\
If the settig is blank (in both files, I think) then it should prompt you to pick the JDK location when you launch it, if you prefer.

another thing you could try is to rename your old jdk folder, lets say its:
C:\Program Files\Java\jdk1.7.0_04
change it to saomething like:
C:\Program Files\Java\xxxjdk1.7.0_04
Now, you should once again asked to set your jdk folder location on Oracle SqlDeveloper launch, and you can chose the right path.
Not the most elegant solution, but it worked for me.
Milos

In your SQL Developer Bin Folder find
\sqldeveloper\bin\sqldeveloper.conf
It should be
SetJavaHome \path\to\jdk
You said it was ../../jdk originally so you could ultimatey do 1 of two things:
SetJavaHome C:\Program Files\Java\jdk1.7.0_60
This is assuming that you have JDK 1.7.60 installed in that directory; you don't want to point it to the bin folder you want the whole JDK folder.
OR
The second thing you can do is find the jdk folder in the sqldeveloper folder for me its sqldeveloper\jdk and copy and paste the contents from C:\Program Files\Java\jdk1.7.0_60. You then have to revert your change to read
SetJavaHome ../../jdk
in your sqldeveloper.conf
If all else fails you can always redownload the sqldeveloper that already contains the jdk7 all zipped up and ready for you to run at will: Download SQL Developer The file I talk about is called Windows 64-bit - zip file includes the JDK 7

I cannot believe Oracle's documentation is SO LAME! In some documents it is misleading people to point to the JDK by specifying the path to the JDK root, e.g. on a Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/
Reviewing /Applications/SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh
revealed the method they use to set up the path:
TMP_PATH=/usr/libexec/java_home -F -v 9
if [ -z "$TMP_PATH" ] ; then
TMP_PATH=/usr/libexec/java_home -F -v 1.8
if [ -z "$TMP_PATH" ] ; then
osascript -e 'tell app "System Events" to display dialog "SQL Developer requires a minimum of Java 8. \nJava 8 can be downloaded from:\n http://www.oracle.com/technetwork/java/javase/downloads/"'
exit 1
fi
fi
Executing this manually from Terminal:
/usr/libexec/java_home -F -v 1.8
Lists the path as:
/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
And this is what you need to specify as the value for
SetJavaHome /Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home
Thank you Oracle for wasting half a day on your "product" that does NOT even support your latest Java version, also released by you.

On Windows,Close all the SQL Developer windows. Then You need to completely delete the SQL Developer and sqldeveloper folders located in user/AppData/Roaming. Finally, run the program, you will be prompted for new JDK.
Note that AppData is a hidden folder.

For those who use Mac, edit this file:
/Applications/SQLDeveloper.app/Contents/MacOS/sqldeveloper.sh
Mine had:
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
and I changed it to 1.8 and it stopped complaining about java version.

if you use sqldeveloper 18.2.0
edit %APPDATA%\sqldeveloper\18.2.0\product.conf
jdk9, jdk10, and jdk11 are not supported
change back to jdk 8
for example
SetJavaHome C:\Program Files\ojdkbuild\java-1.8.0-openjdk-1.8.0.191-1

Related

javac is not recognized as internal command [duplicate]

This question already has answers here:
javac is not recognized as an internal or external command in windows 7
(3 answers)
Closed 2 years ago.
My current system config is -
Netbeans 12.0
JDK 14.0.2
Windows 10 (64bit)
I have added the environmental variable in PATH manually i.e. C:\Program Files\Java\jdk-14.0.2\bin.
I tried adding using cmd as well. As well as adding the JAVA_HOME as a new variable with value as C:\Program Files\Java\jdk-14.0.2 .
I have used the set command to do this process i.e. set path = "%path%;"C:\Program Files\Java\jdk-14.0.2\bin". Also, I have used the same command without the set keyword.
Since javah command was deprecated for versions of jdk>8, I have tried to use javac -h command as well.
I have also tried to install JDK v. 8.0.2 instead of the current one.
Although there's no javah.exe file in the bin folder, there is however javac.exe file.
I have uninstalled and reinstalled JDK and Netbeans quite a few times.
I am currently working on JNI with Netbeans IDE and C/C++ plugin. (I have successfully installed Cygwin and necessary extension for the file to build. Although I don't know how they affect this problem, still I thought I should add this).
The command I wish to use with 'javah' is the one used for creating a C header from a Java class i.e. 'javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main'.
But due to this error, I have been stuck for a few days. Please do assist.
Following way you can set Path variable temporary(it can only be used in the same command line):
You should do it this way:(notice =)
set PATH=C:\Program Files\Java\jdk-14.0.2\bin
And if you set JAVA_HOME variable correctly you can do it this way:
set PATH="%JAVA_HOME%\bin"
For setting this permanently read this post :
https://javatutorial.net/set-java-home-windows-10
We should know the reason for this
Our OS comes with a predefined (built-in)set of tools and utilities. When we try to execute the command e.g. cls in the Windows command line then it is already present in system path variable and os will refer the corresponding binary of cls to execute the command.
However, when we install any third party tool/software then path variable is not updated accordingly.
When we install different versions of java on your system then installations go to different directories. E.g. JDK installation directory for Windows will be
C:\Program Files\Java\jdk1.8.0_161
Similarly, JRE installation directory for Windows will be JDK installation directory for Windows will be
C:\Program Files\Java\jre1.8.0_161
We need to update the path variable of OS to point to the appropriate directory. If we set the path of JDK then it will execute a binary from JDK bin directory.
Solution
we need to update JDK or JRE version specific directory location into PATH Environment variable.
In this case use
set path=C:\Program Files\Java\jdk-14.0.2\bin to set JAVA_PATH

Gradle not found java class path [duplicate]

I am using javadoc doclets with gradle, so I need to use the package tools.jar, which is in the lib folder from the jdk (1.6.0_26 in my case).
The point is that gradle does not take it automatically, so I was adding that tools package to my libs folder, and then adding it to dependencies.gradle .
Now I want to take it directly from my JDK home into my dependencies.gradle. Is there a way to do that? I have tried the next in my dependencies.gradle:
compile files("${System.properties['java.home']}/lib/tools.jar")
But it does not find it while compiling.
I had this problem when I was trying to run commands through CLI.
It was a problem with system looking at the JRE folder i.e.
D:\Program Files\Java\jre8\bin. If we look in there, there is no Tools.jar, hence the error.
You need to find where the JDK is, in my case: D:\Program Files\Java\jdk1.8.0_11, and if you look in the lib directory, you will see Tools.jar.
What I did I created a new environment variable JAVA_HOME:
And then you need to edit your PATH variable to include JAVA_HOME, i.e. %JAVA_HOME%/bin;
Re-open command prompt and should run.
Found it. System property 'java.home' is not JAVA_HOME environment variable. JAVA_HOME points to the JDK, while java.home points to the JRE. See that page for more info.
Soo... My problem was that my startpoint was the jre folder (C:\jdk1.6.0_26\jre) and not the jdk folder (C:\jdk1.6.0_26) as I thought(tools.jar is on the C:\jdk1.6.0_26\lib folder ). The compile line in dependencies.gradle should be:
compile files("${System.properties['java.home']}/../lib/tools.jar")
I got the same error using Eclipse trying to execute a Gradle Task. Every time I run a command (i.e. war) the process threw an exception like:
Could not find tools.jar. Please check that C:\Program Files\Java\Jre8" is a valid JDK install.
I tried the solution listed in this post but none of them solved this issue. Here my solution :
Go to the "Gradle Task" view
Right Click on the task you want to execute
Select Open Gradle Run Configuration
In the tab "Java Home" select your local JDK repository then click OK
Run again, Enjoy!
I just added a gradle.properties file with the following content:
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_45
I had a similar case using Ubuntu. The machine had only the JRE installed. So, I just executed the command below to install the JDK.
sudo apt install openjdk-8-jdk
In macOS Big Sur
The issue happens because of the environment variable JAVA_HOME is not correctly set in macOS Big Sur.
Step 1 - Confirm that you have issue with JAVA_HOME by printing its value in the terminal. You will most likely get an empty string.
echo $JAVA_HOME
Step 2 - Find the correct path on your machine
/usr/libexec/java_home -V
Copy that path associated with "Java SE 8" which usually looks like /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
Step 3 - Edit .zshenv using nano
nano ~/.zshenv
Step 4 - Add the path from step 2 to the file as follows
export JAVA_HOME=YOUR_JAVA_PATH
example:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
Step 5 - Source the updated .zshenv file to activate the environment variable
source ~/.zshenv
Step 6 - Print to confirm the path
echo $JAVA_HOME
I was struggling as well for this Solution. Found a better way to it with Gradle as described here.
We can get the JVM/JDK information from Gradle itself.
dependencies {
runtime files(org.gradle.internal.jvm.Jvm.current().toolsJar)
}
So simple.
In CentOS7 the development package will install tools.jar. The file is not present in java-1.8.0-openjdk
sudo yum install java-1.8.0-openjdk-devel
Add this to gradle.properties:
org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_91
My solution on Mac:
add this line to gradle.properties:
org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
not this one:
org.gradle.java.home=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
you can open the last home directory and will find that there is no lib/tools.jar file existence, so change the path to JavaVirtualMachines/jdk1.8.0_271.jdk and it works for me.
By the way, in the terminal, I echo the $JAVA_HOME and it gets the first path, not the second one, I think this is why my Gradle cannot work properly.
With Centos 7, I have found that only JDK has tools.jar, while JRE has not. I have installed the Java 8 JRE(yum install java-1.8.0-openjdk), but not the JDK(yum install java-1.8.0-openjdk-devel).
Installing the latter solves the problem. Also, remember to set JAVA_HOME.
It may be two years too late, but I ran into the same problem recently and this is the solution I ended up with after finding this post:
import javax.tools.ToolProvider
dependencies {
compile (
files(((URLClassLoader) ToolProvider.getSystemToolClassLoader()).getURLs()),
...
}
}
It should work if java.home points to a directory that's not under the JDK directory and even on Mac OS where you'd have classes.jar instead of tools.jar.
On windows 10, I encounter the same problem and this how I fixed the issue;
Access Advance System Settings>Environment Variables>System
Variables
Select PATH overwrite the default
C:\ProgramData\Oracle\Java\javapath
With your own jdk installation that is JAVA_HOME=C:\Program Files\Java\jdk1.8.0_162
On my system (Win 10, JRE 1.8.0, Android Studio 3.1.2, Gradle 4.1) there is no tools.jar in the JRE directory (C:\Program Files\Java\jre1.8.0_171).
However, I found it in C:\Program Files\Android\Android Studio\jre\lib and tried setting JAVA_HOME=C:\Program Files\Android\Android Studio\jre
That works (for me)!
What solved it for me was the following:
found tools.jar in C:\Program Files\Android\Android Studio\jre\lib
copy paste to C:\Program Files (x86)\Java\jre1.8.0_271\lib
ran the code again and it worked.
If you use terminal to build and you have this error you can point to jdk bundled with android studio in your gradle.properties file:
org.gradle.java.home=/usr/local/android-studio/jre
Linux
Open /etc/environment in any text editor like nano or gedit and add the following line:
JAVA_HOME="/usr/lib/jvm/open-jdk"
Windows
Start the System Control Panel applet (Start - Settings - Control
Panel - System).
Select the Advanced tab.
Click the Environment
Variables button.
Under System Variables, click add button, then past the following lines:
in Variable Name : JAVA_HOME
in Variable Value : C:\Program Files\Java\jdk1.x.x_xxx
where x.x_xxx jdk version you can get your jdk version from here C:\Program Files\Java
Under System Variables, select Path, then click Edit,then click new button then past the following line:
%JAVA_HOME%/bin;
This worked for me:
I was getting message
Execution failed for task ':app:compileDebugJavaWithJavac'.
Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_121 contains a valid JDK installation.
In Android Studio, check your SDK Location.
File, Project Structure, SDK Location, JDK Location.
Example: C:\android-studio\android-studio\jre
Copy the tools.jar file in the C:\android-studio\android-studio\jre\lib folder into the C:\Program Files\Java\jre1.8.0_121\lib folder.
Retry.
Like other answers I set org.gradle.java.home property in gradle.properties file. But path with \ separators did not work (building on windows 10):
Java home supplied via 'org.gradle.java.home' is invalid. Invalid
directory: C:Program FilesJavajdk1.8.0_65
So instead of
org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_65
i had to use
org.gradle.java.home=C:/Program Files/Java/jdk1.8.0_65
then the build was successful
Problem is that project is build with JRE instead of JDK and since I was building it from eclipse this also worked:
In Window>Preferences>Gradle>Arguments specify Workspace JRE and specify your JDK.
In Window>Preferences>Java>InstalledJREs specify your JDK as default
In my case (Windows 10) after Java update I lost my Enviroment Variables, so I fixed added the variables again, based in the following steps https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html
I solved problem on this way:
download file tools-1.8.0.jar on http://www.java2s.com/Code/Jar/t/Downloadtools180jar.htm
unzip file and rename to tools.jar
copy to C:\Program Files\Java\jre1.8.0_191\lib folder
Retry
Put in gradle.properties file the following code line:
org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_45
Example image
Use this with modern versions of gradle:
def compiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(java.sourceCompatibility.majorVersion) }.get()
implementation compiler.metadata.installationPath.files('lib/tools.jar')
Did you make sure that tools.jar made it on the compile class path? Maybe the path is incorrect.
task debug << {
configurations.compile.each { println it }
}
Adding JDK path through JAVA_HOME tab in "Open Gradle Run Configuration" will solve the problem.
Could not find tools.jar
MacOS
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
And restart Shell
I've tried most of the top options but it seems that I had something wrong with my environment setup so they didn't help. What solved the issue for me was to re-install jdk1.8.0_201 and jre1.8.0_201 and this solved the error for me. Hope that helps someone.
For me this error ocurred after trying to use audioplayers flutter library.
To solve i got tools.jar of the folder:
C:\Program Files\Android\Android Studio\jre\lib
and pasted on
C:\Program Files\Java\jre1.8.0_181\lib.
After this the build worked fine.
My Android Studio Version: 4.2.1
The "tools.jar" is provided by Oracle JDK which is required by android studio for compilation - I have faced this issue after updating android studio to latest version in my PC.
To Resolve the issue follow below steps:
In Android studio File -> Project Structure -> SDKs (Under Platform Settings)
A) Add JDK path by pressing '+' symbol in middle pane if suppose JDK/JDK home path is not present in the middle pane already (Middle pane also contains the Downloaded Android SDK's)
B) Java sdk will be usually present/installed in the path 64 bit => "C:\Program Files\Java\jdk1.X.Y_ABC" (In my PC it is 1.8.0_202) or 32 bit => "C:\Program Files (x86)\Java\jdk1.X.Y_ABC"
If suppose you don't have JDK installed in your PC,
please download and install from Oracle Java website
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
Set JDK and JRE Path(Download both from webpage mentioned in step 2) in system environment variable
A) Press windows key type "Edit the system environment variables" and open the application
B) Go to Advanced -> Environment Variables Under system variables add JAVA_HOME and JRE_HOME as below
Set Windows system environment variable
Add jdk lib path on the Path environment variable under user variables (this step is required only if the error not resolves with the previous steps)
C:\Program Files\Java\jdk1.X.Y_ABC\lib
For Windows add JDK home path to the Gradle property file as org.gradle.java.home.
If you don't have gradle.properties file then create a new one and add
Ex: org.gradle.java.home=C:\Program Files\Java\jdk1.8.0_241

mvn could not find or load main class org.codehaus.plexus.classworlds.launcher.launcher [duplicate]

I have installed a latest maven-3.0.4 on Windows 7:
The installation details are as follows:
Installation Path :
C:\apache-maven-3.0.4
Environment Variables are:
M2_HOME C:\apache-maven-3.0.4\apache-maven\src
JAVA_HOME C:\Program Files\Java\jdk-1.7.0_04
Path variables added are:
%M2_HOME%\bin;%JAVA_HOME%\bin;
In the command window it shows it like this:
C:\>java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b22)
Java HotSpot(TM) Client VM (build 23.0-b21, mixed mode, sharing)
C:\>mvn -version
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
This is the only version on maven installed on my PC and the solution given on many blogs referring to the deletion of the previous M2_HOME environment variable is not valid.
I have read and tried all the solutions given at blogs such as :
oracle blog,
stackoverflow question,
another stack question,
some blog,
But I'm still not able to get to it. What I might be missing in this whole thing?
I hit this problem too, and found this article. For Maven3, changing my environment variable name from M2_HOME to M3_HOME did the trick. I am on a Mac running OSX 10.9 with JDK 1.7.
Note: Please delete M2_HOME, if already set. Eg: unset M2_HOME.
Even though the question is answered I would like to add that, if you are getting the above mentioned error, be sure that you have downloaded the Binary file.
The source file should only be downloaded if you are an advanced user and that you know how to deal with it.
I have had quite a share of people downloading the wrong file, seniors and juniors
I was having this same problem and was able to resolve it by carefully redoing the Environment Variables:
M2_HOME
M2
JAVA_HOME
Also, I made them all System Variables, not User Variables like the Maven instructions say. When you
echo %Path%
Make sure you can see the %M2% and %JAVA_HOME% variables completely expanded, i.e. :
C:\Users\afairchild>echo %Path%
C:\Program Files\Apache Software Foundation\apache-maven-3.0.4\bin;C:\Program Files\Java\jdk1.7.0_09\bin; [etc]
I believe this error caused because of downloading SRC instead of BINARY from Maven site. Please make sure to download Binary zip.
Because the below path, you will get only when you download SRC:
M2_HOME C:\apache-maven-3.0.4\apache-maven\src
Had this issue on two different Ubuntu 12.04 installs, despite the installs being done by apt-get. Issue was M2_HOME.
Fixed with:
export M2_HOME=/usr/share/maven
It sounds like you installed (extracted) the source files instead of the binaries based on your path information. Try installing the binaries instead and following the other posters answer.
Well, I had this problem and after seeing this post and particularly khmarbaise answer I noticed that M2_HOME was
D:\workspace\apache-maven-3.1.0-bin\apache-maven-3.1.0\bin
and then I chaged it to
D:\workspace\apache-maven-3.1.0-bin\apache-maven-3.1.0
I would like to mention that I use windows 7 (x64)
The solution for later versions of Maven is straight-forward. I am on OS X ElCap, 10.11.6 and upgraded to Maven 3.3.9. I had the same problem with error "Could not find ...org.codehaus.plexus...". The link provided here offered the solution in a comment by McKamey - simply delete M2_HOME (unset M2_HOME). Once I tried that, it all worked as expected.
This can be confirmed by visiting the Maven install page: "Add the bin directory of the created directory apache-maven-3.3.9 to the PATH environment variable" -- no mention of M2_HOME or M3_HOME at all.
For most of the Maven setup issues something like "Could not find or load main class...", start-with below steps to see if that fixes:
Make sure you unzipped the right archive (BINARY archive and not SOURCE archive)
Remove all user and system variables related to Maven (ex. M2_HOME,M2_OPTS etc.)
Make sure JAVA_HOME system variable is setup (ex. "C:\Program Files\Java\jdk1.8.0_172")
Make sure java bin location is added in "path" system variable (ex. "%JAVA_HOME%\bin")
Make sure maven bin location is added in "path" system variable (ex. "C:\MyInstalls\apache-maven-3.5.4\bin")
then...
Verify java is setup (at commandprompt : java -version)
Verify maven is setup (at commandprompt : mvn --version)
Open a new terminal and do the followin
M2_HOME=/Users/macbook/apache-maven-3.6.1 //Set where maven is
M2=$M2_HOME/bin //Set home as bin
export PATH=$M2:$PATH //Place the new path
Then type
mvn -version
You can set this in ./bash_profile to do it automatically each time you run the terminal
You should change the location of the M2_HOME into the following:
set M2_HOME=C:\apache-maven-3.0.4\apache-maven
Furthermore the installation of the JDK looks more a JRE instead of JDK. For Maven you need JDK and NOT JRE.
I came across a similar problem on my mac OSX. After a series of trial and error attempts I finally resolved it.
My ~/.bash_profile looked like this
export M2_HOME=/Users/xyz/maven-3.x/bin
export PATH=$PATH:$M2_HOME
and when I tried to echo M2_HOME from the terminal, it showed me the correct path but when I tried to fire any maven command like mvn clean or mvn install, it always gave the same problem
Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
I solved this issue by changing my M2_HOME to this
export M2_HOME=/Users/xyz/maven-3.x
export PATH=$PATH:$M2_HOME/bin
And voila ! It started working ! Just by moving the position of /bin from M2_HOME to in front of the PATH
Just make sure you've downloaded Binary zip archive(apache-maven-3.5.0-bin.zip) instead of Source zip archive. Then add the bin directory of the created directory apache-maven-3.5.0 to the PATH environment variable.
install binary version of maven fixes the issues
apache-maven-3.6.1-bin.zip
I had the same issue. I have Windows xp box and when I would type mvn -version at the command line prompt I got the dreaded error message
"Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher"
I confirmed that my M2_HOME variable was set to the path where Maven was installed on pc and that the echo %path% confirmed that Maven was in my path.
I have been searching for a solution for hours when I stumbled on to my solution (I say my solution because I know this probably won't be the solution for everyone that is getting the same error).
I copied the path that was assigned to my M2_HOME variable. I opened a cmd window and typed cd and pasted the path I got from my M2_HOME variable. At that point I knew that the path was correct because the path was displayed in the window. At this point I entered the dir command and to my surprise, I got the error File Not Found.
I went to that path via Explorer and sure enough there were files present. I noticed that the folders were faded out, but I could access them and see the files within each folder (I have admin rights on my pc). I looked at the properties of the parent folder for Maven and saw that the Hidden box was checked. I removed the check and applied and tried my dir command again with success.
Next I tried the mvn –version command again, but this time I got back the expected results.
C:\>mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
Maven home: C:\Program Files\apache-maven-3.0.3
Java version: 1.5.0_16, vendor: Sun Microsystems Inc.
Java home: C:\Java\jdk1.5.0_16\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"
Finally I created a jar and war file and my web app ran successfully on my local Tomcat.
I hope this helps some of you out there.
Besides what #khmarbaise has pointed out, I think you have mistyped your JAVA_HOME. If you have installed in the default location, then there should be no "-" (hyphen) between jdk and 1.7.0_04. So it would be
JAVA_HOME C:\Program Files\Java\jdk1.7.0_04
For other people who might run into this, don't forget to check ~/.mavenrc for M2_HOME or JAVA_HOME settings.
Try to download binary zip (for ex. Maven 3.0.5 (Binary zip)) instead of complete source in official maven site.
Also make sure that command line recognizes java and javac commands.
I noticed that Maven Source zip didn't include any libraries at lib folder however Binary zip had them + in boot folder it had plexus-classworlds-2.4.jar. Perhaps the problem was with the absence of these libraries. Anyway it helped me so my M2_HOME is: C:\Program Files\Java\apache-maven-3.0.5 and at PATH I put: C:\Program Files\Java\apache-maven-3.0.5\bin.
I find this issue in my centOS is caused by "Oracle Java is replace by gcj", after change default java to "Oracle Java", the issue is resolved.
alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
+ 2 /usr/java/jdk1.7.0_67/bin/java
It look like that you have installed Source files(Because src only comes in Source Files and we don't need it). Try to install Binary Files from
there.
And then set environment variables as described
there.
This worked for me. And I am sure it will also work for you.
I think you download the wrong version.
I meet this problem just now, no method work after searching and searching.
Finally, I found that maven I downloaded is Source zip archive.
After I change to Binary zip archive, everything go to be fine.
Me too faced the similar issue. But in my case I used apache-maven-3.3.3-src folder in path variables. Later I corrected those with correct path of folder apache-maven-3.3.3-bin. This resolved the issue. Am not telling that is the same error reported here but this way also you can get this error and rectify it. That is what I am trying to say here.
Exactly the same error may appear even with correct environment variable settings, if you copy ONLY bin directory to the installation directory.
It make which work finely, and novices get stuck.
Next to the maybe useful, but maybe too symptomatic answers, here is one which tries to help to find the cause of the problem.
Maven is a command-line java tool. That means, it is not a standalone binary, it is a collection of java .jars, interpreted by a jvm (java.exe on windows, java on linux).
The mvn command, is a script. On windows, it is a script called mvn.cmd and on linux, it is a shell script. Thus, if you write: mvn install, what will happen:
a command interpreter (/bin/sh or cmd.exe) is called for the actual invoking script
this script sets the needed environment variables
and finally, it calls a java interpreter with the the required classpath which contain the maven functionality.
The problem is with (2). Fortunately, this script is simply, very simple. For a java programmer it shouldn't be a big trouble to debug a script around 20 lines, even if it is a little bit alien language.
On linux, you can debug shellscripts giving the -x flag to your shell interpreter (which is most probably bash). On windows, you have to find some other way to debug a cmd.exe script. So, instead of mvn install, give the command bash -x mvn install.
The result be like:
+ '[' -z '' ']'
+ '[' -f /etc/mavenrc ']'
+ '[' -f /home/picsa/.mavenrc ']'
+ cygwin=true
+ darwin=false
...not so many things...
+ MAVEN_PROJECTBASEDIR='C:\peter\bin'
+ export MAVEN_PROJECTBASEDIR
+ MAVEN_CMD_LINE_ARGS=' '
+ export MAVEN_CMD_LINE_ARGS
+ exec '/cygdrive/c/Program Files/Java/jdk1.8.0_66/bin/java' -classpath 'C:\peter/boot/plexus-classworlds-*.jar' '-Dclassworlds.conf=C:\peter/bin/m2.conf' '-Dmaven.home=C:\peter' '-Dmaven.multiModuleProjectDirectory=C:\peter\bin' org.codehaus.plexus.classworlds.launcher.Launcher
Fehler: Hauptklasse org.codehaus.plexus.classworlds.launcher.Launcher konnte nicht gefunden oder geladen werden
At the end, you can easily test, which environment variable gone bad, and you can very easily fix your script (or set it what is needed).
I had this problem when I used Maven 3.5.4 on OpenJDK 11 on Ubuntu. The OpenJDK 11 on Ubuntu is actually still a JDK10:
$ ls -al /etc/alternatives/java
lrwxrwxrwx 1 root root 43 Aug 24 04:54 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java
$ java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3, mixed mode)
I installed OpenJDK from Oracle into /opt/jdk-11.0.1 and run Maven like this:
JAVA_HOME=/opt/jdk-11.0.1 mvn
It now works like a charm.
I had a problem with surefire plugin itself. Going back to version 2.6 worked for me. Version 2.18/20/22.1 gave me the error.
Now I tried version 3.0.0-M1 of surefire plugin and it works.
So something is wrong in surefire plgin between version 2.6 and 3.0.0. I assume there is something hardcoded as default which should not.
For me, funny as it sounds, it helped just restarting eclipse...
This worked for me:
Remove all Mavin references in Environment Variables
Download the Binary from mavin
Unzip it to where you'd like ex: C:\apache-maven-3.6.0
Go to Environment variables and add to System variable path "C:\apache-maven-3.6.0\bin"
start command prompt as Administrator
check version with: mvn -v
CMD Result:
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: C:\apache-maven-3.6.0\bin..
I also faced the following Error in my system (Mac)
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
After doing some random browsing, I came across the link "http://maven.apache.org/install.html" that says "JAVA_HOME" should be set to "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre".
When I changed "JAVA_HOME" as stated above in ".bash_profile", "mvn" command started working but "javac -version" command stopped working.
When I typed "javac -version" command, I got the following error
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/bin/javac" (-1)
Hence I rolled back my "JAVA_HOME" to "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home" in ".bash_profile" and added the following line at the top in "mvn" script
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
Now both "mvn" and "javac" commands worked properly, but after careful observation of the mvn script, I could not make the difference between the following commands
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java -classpath /Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar -Dclassworlds.conf=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin/m2.conf -Dmaven.home=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1 -Dlibrary.jansi.path=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin org.codehaus.plexus.classworlds.launcher.Launcher
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/bin/java -classpath /Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar -Dclassworlds.conf=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin/m2.conf -Dmaven.home=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1 -Dlibrary.jansi.path=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin org.codehaus.plexus.classworlds.launcher.Launcher
In the above the first command caused the following error
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
while the second command worked fine.
Please Note that both the above paths have "java" command while one is from "jre" the other is from "jdk"
Other global variables are as following in ".bash_profile"
export M2_HOME=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1
export PATH=$PATH:$M2_HOME/bin
Was able to solve this issue by deleting the downloaded maven in my machine ( /Users/kkohli/Desktop/Personal/Code/Java/apache-maven-3.6.3 ) and re-downloading the binary version from the apache site. Did not modify any other bashprofile file etc ( My M2_HOME, JAVA_HOME etc are set inside my bashprofile)

Eclipse is not opening

I'm new to java and eclipse. I even saw this type of query on this website. But I have applied all those methods and it was also helpful. But when I try to open eclipse, it is not opening:
This is my path for java
C:\Program Files (x86)\Java\jre6
this is where my eclipse is
C:\Users\New folder\eclipse
But when I run the eclipse I'm getting an error
"A java rumtime environment(JRE) or java development kit(JDK) must be
available in order to run eclipse. No java virtual machine was found
after searching the following location: C:\Users\New
folder\eclipse\jre\bin\javaw.exe javaw.exe in your current path"
Please tell me the possible solution.
Thanks in advance!
If you have installed jdk then Eclipse won't have any issue to start. I think you just have installed JRE to run java programs. You need to install JDK.
To check whether you have installed JDK. Check Path C:\Program Files (x86)\Java. Your Java directory should contain directory jdk1.6.., If you don't have this directory there, search it at other places. If you did not find directory then you didn't install JDK.
Download JDK from here.
You should set JAVA_HOME and JRE_HOME variable. http://www.javawebonline.com/java-se-programming/beginners/java_home-jre_home-environment-variables/
And another suggestion is you should move your java home to another location and test your path to java such as
C:\Java\jre6
instead of
C:\Program Files (x86)\Java\jre6.
Go to C:\Users\New folder\eclipse
Open eclipse.ini file with text editor and add the javaw location there
( right after -vm part ) like so:
-vm
C:/Program Files/Java/jdk1.6.0_33/bin/javaw.exe <--- change to your path
-vmargs
Open the command prompt by pressing Windows+r, type cmd and press Enter.
Type javac and check the output.
If it gives all the options and usage, then you have configured the PATH vairables correctly, or else you have not set them up correctly.
Try it by checking the value at the command prompt.
NOTE
You need to open a new command prompt each time you change the environment variables.
If you have two Program Files folder in your C: drive
such as
C:\Program Files
C:\Program Files (x86)
then try to put your java inside
C:\Program Files
instead of C:\Program Files (x86)
It seems you are running 64 bit eclipse in 64 bit operating system. If you are running 64 bit eclipse then you need 64 bit JDK. Please install 64 bit JDK and run eclipse.

Maven error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

I have installed a latest maven-3.0.4 on Windows 7:
The installation details are as follows:
Installation Path :
C:\apache-maven-3.0.4
Environment Variables are:
M2_HOME C:\apache-maven-3.0.4\apache-maven\src
JAVA_HOME C:\Program Files\Java\jdk-1.7.0_04
Path variables added are:
%M2_HOME%\bin;%JAVA_HOME%\bin;
In the command window it shows it like this:
C:\>java -version
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b22)
Java HotSpot(TM) Client VM (build 23.0-b21, mixed mode, sharing)
C:\>mvn -version
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
This is the only version on maven installed on my PC and the solution given on many blogs referring to the deletion of the previous M2_HOME environment variable is not valid.
I have read and tried all the solutions given at blogs such as :
oracle blog,
stackoverflow question,
another stack question,
some blog,
But I'm still not able to get to it. What I might be missing in this whole thing?
I hit this problem too, and found this article. For Maven3, changing my environment variable name from M2_HOME to M3_HOME did the trick. I am on a Mac running OSX 10.9 with JDK 1.7.
Note: Please delete M2_HOME, if already set. Eg: unset M2_HOME.
Even though the question is answered I would like to add that, if you are getting the above mentioned error, be sure that you have downloaded the Binary file.
The source file should only be downloaded if you are an advanced user and that you know how to deal with it.
I have had quite a share of people downloading the wrong file, seniors and juniors
I was having this same problem and was able to resolve it by carefully redoing the Environment Variables:
M2_HOME
M2
JAVA_HOME
Also, I made them all System Variables, not User Variables like the Maven instructions say. When you
echo %Path%
Make sure you can see the %M2% and %JAVA_HOME% variables completely expanded, i.e. :
C:\Users\afairchild>echo %Path%
C:\Program Files\Apache Software Foundation\apache-maven-3.0.4\bin;C:\Program Files\Java\jdk1.7.0_09\bin; [etc]
I believe this error caused because of downloading SRC instead of BINARY from Maven site. Please make sure to download Binary zip.
Because the below path, you will get only when you download SRC:
M2_HOME C:\apache-maven-3.0.4\apache-maven\src
Had this issue on two different Ubuntu 12.04 installs, despite the installs being done by apt-get. Issue was M2_HOME.
Fixed with:
export M2_HOME=/usr/share/maven
It sounds like you installed (extracted) the source files instead of the binaries based on your path information. Try installing the binaries instead and following the other posters answer.
Well, I had this problem and after seeing this post and particularly khmarbaise answer I noticed that M2_HOME was
D:\workspace\apache-maven-3.1.0-bin\apache-maven-3.1.0\bin
and then I chaged it to
D:\workspace\apache-maven-3.1.0-bin\apache-maven-3.1.0
I would like to mention that I use windows 7 (x64)
The solution for later versions of Maven is straight-forward. I am on OS X ElCap, 10.11.6 and upgraded to Maven 3.3.9. I had the same problem with error "Could not find ...org.codehaus.plexus...". The link provided here offered the solution in a comment by McKamey - simply delete M2_HOME (unset M2_HOME). Once I tried that, it all worked as expected.
This can be confirmed by visiting the Maven install page: "Add the bin directory of the created directory apache-maven-3.3.9 to the PATH environment variable" -- no mention of M2_HOME or M3_HOME at all.
For most of the Maven setup issues something like "Could not find or load main class...", start-with below steps to see if that fixes:
Make sure you unzipped the right archive (BINARY archive and not SOURCE archive)
Remove all user and system variables related to Maven (ex. M2_HOME,M2_OPTS etc.)
Make sure JAVA_HOME system variable is setup (ex. "C:\Program Files\Java\jdk1.8.0_172")
Make sure java bin location is added in "path" system variable (ex. "%JAVA_HOME%\bin")
Make sure maven bin location is added in "path" system variable (ex. "C:\MyInstalls\apache-maven-3.5.4\bin")
then...
Verify java is setup (at commandprompt : java -version)
Verify maven is setup (at commandprompt : mvn --version)
Open a new terminal and do the followin
M2_HOME=/Users/macbook/apache-maven-3.6.1 //Set where maven is
M2=$M2_HOME/bin //Set home as bin
export PATH=$M2:$PATH //Place the new path
Then type
mvn -version
You can set this in ./bash_profile to do it automatically each time you run the terminal
You should change the location of the M2_HOME into the following:
set M2_HOME=C:\apache-maven-3.0.4\apache-maven
Furthermore the installation of the JDK looks more a JRE instead of JDK. For Maven you need JDK and NOT JRE.
I came across a similar problem on my mac OSX. After a series of trial and error attempts I finally resolved it.
My ~/.bash_profile looked like this
export M2_HOME=/Users/xyz/maven-3.x/bin
export PATH=$PATH:$M2_HOME
and when I tried to echo M2_HOME from the terminal, it showed me the correct path but when I tried to fire any maven command like mvn clean or mvn install, it always gave the same problem
Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
I solved this issue by changing my M2_HOME to this
export M2_HOME=/Users/xyz/maven-3.x
export PATH=$PATH:$M2_HOME/bin
And voila ! It started working ! Just by moving the position of /bin from M2_HOME to in front of the PATH
Just make sure you've downloaded Binary zip archive(apache-maven-3.5.0-bin.zip) instead of Source zip archive. Then add the bin directory of the created directory apache-maven-3.5.0 to the PATH environment variable.
install binary version of maven fixes the issues
apache-maven-3.6.1-bin.zip
I had the same issue. I have Windows xp box and when I would type mvn -version at the command line prompt I got the dreaded error message
"Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/launcher/Launcher"
I confirmed that my M2_HOME variable was set to the path where Maven was installed on pc and that the echo %path% confirmed that Maven was in my path.
I have been searching for a solution for hours when I stumbled on to my solution (I say my solution because I know this probably won't be the solution for everyone that is getting the same error).
I copied the path that was assigned to my M2_HOME variable. I opened a cmd window and typed cd and pasted the path I got from my M2_HOME variable. At that point I knew that the path was correct because the path was displayed in the window. At this point I entered the dir command and to my surprise, I got the error File Not Found.
I went to that path via Explorer and sure enough there were files present. I noticed that the folders were faded out, but I could access them and see the files within each folder (I have admin rights on my pc). I looked at the properties of the parent folder for Maven and saw that the Hidden box was checked. I removed the check and applied and tried my dir command again with success.
Next I tried the mvn –version command again, but this time I got back the expected results.
C:\>mvn -version
Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600)
Maven home: C:\Program Files\apache-maven-3.0.3
Java version: 1.5.0_16, vendor: Sun Microsystems Inc.
Java home: C:\Java\jdk1.5.0_16\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows xp", version: "5.1", arch: "x86", family: "windows"
Finally I created a jar and war file and my web app ran successfully on my local Tomcat.
I hope this helps some of you out there.
Besides what #khmarbaise has pointed out, I think you have mistyped your JAVA_HOME. If you have installed in the default location, then there should be no "-" (hyphen) between jdk and 1.7.0_04. So it would be
JAVA_HOME C:\Program Files\Java\jdk1.7.0_04
For other people who might run into this, don't forget to check ~/.mavenrc for M2_HOME or JAVA_HOME settings.
Try to download binary zip (for ex. Maven 3.0.5 (Binary zip)) instead of complete source in official maven site.
Also make sure that command line recognizes java and javac commands.
I noticed that Maven Source zip didn't include any libraries at lib folder however Binary zip had them + in boot folder it had plexus-classworlds-2.4.jar. Perhaps the problem was with the absence of these libraries. Anyway it helped me so my M2_HOME is: C:\Program Files\Java\apache-maven-3.0.5 and at PATH I put: C:\Program Files\Java\apache-maven-3.0.5\bin.
I find this issue in my centOS is caused by "Oracle Java is replace by gcj", after change default java to "Oracle Java", the issue is resolved.
alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
* 1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
+ 2 /usr/java/jdk1.7.0_67/bin/java
It look like that you have installed Source files(Because src only comes in Source Files and we don't need it). Try to install Binary Files from
there.
And then set environment variables as described
there.
This worked for me. And I am sure it will also work for you.
I think you download the wrong version.
I meet this problem just now, no method work after searching and searching.
Finally, I found that maven I downloaded is Source zip archive.
After I change to Binary zip archive, everything go to be fine.
Me too faced the similar issue. But in my case I used apache-maven-3.3.3-src folder in path variables. Later I corrected those with correct path of folder apache-maven-3.3.3-bin. This resolved the issue. Am not telling that is the same error reported here but this way also you can get this error and rectify it. That is what I am trying to say here.
Exactly the same error may appear even with correct environment variable settings, if you copy ONLY bin directory to the installation directory.
It make which work finely, and novices get stuck.
Next to the maybe useful, but maybe too symptomatic answers, here is one which tries to help to find the cause of the problem.
Maven is a command-line java tool. That means, it is not a standalone binary, it is a collection of java .jars, interpreted by a jvm (java.exe on windows, java on linux).
The mvn command, is a script. On windows, it is a script called mvn.cmd and on linux, it is a shell script. Thus, if you write: mvn install, what will happen:
a command interpreter (/bin/sh or cmd.exe) is called for the actual invoking script
this script sets the needed environment variables
and finally, it calls a java interpreter with the the required classpath which contain the maven functionality.
The problem is with (2). Fortunately, this script is simply, very simple. For a java programmer it shouldn't be a big trouble to debug a script around 20 lines, even if it is a little bit alien language.
On linux, you can debug shellscripts giving the -x flag to your shell interpreter (which is most probably bash). On windows, you have to find some other way to debug a cmd.exe script. So, instead of mvn install, give the command bash -x mvn install.
The result be like:
+ '[' -z '' ']'
+ '[' -f /etc/mavenrc ']'
+ '[' -f /home/picsa/.mavenrc ']'
+ cygwin=true
+ darwin=false
...not so many things...
+ MAVEN_PROJECTBASEDIR='C:\peter\bin'
+ export MAVEN_PROJECTBASEDIR
+ MAVEN_CMD_LINE_ARGS=' '
+ export MAVEN_CMD_LINE_ARGS
+ exec '/cygdrive/c/Program Files/Java/jdk1.8.0_66/bin/java' -classpath 'C:\peter/boot/plexus-classworlds-*.jar' '-Dclassworlds.conf=C:\peter/bin/m2.conf' '-Dmaven.home=C:\peter' '-Dmaven.multiModuleProjectDirectory=C:\peter\bin' org.codehaus.plexus.classworlds.launcher.Launcher
Fehler: Hauptklasse org.codehaus.plexus.classworlds.launcher.Launcher konnte nicht gefunden oder geladen werden
At the end, you can easily test, which environment variable gone bad, and you can very easily fix your script (or set it what is needed).
I had this problem when I used Maven 3.5.4 on OpenJDK 11 on Ubuntu. The OpenJDK 11 on Ubuntu is actually still a JDK10:
$ ls -al /etc/alternatives/java
lrwxrwxrwx 1 root root 43 Aug 24 04:54 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-amd64/bin/java
$ java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3, mixed mode)
I installed OpenJDK from Oracle into /opt/jdk-11.0.1 and run Maven like this:
JAVA_HOME=/opt/jdk-11.0.1 mvn
It now works like a charm.
I had a problem with surefire plugin itself. Going back to version 2.6 worked for me. Version 2.18/20/22.1 gave me the error.
Now I tried version 3.0.0-M1 of surefire plugin and it works.
So something is wrong in surefire plgin between version 2.6 and 3.0.0. I assume there is something hardcoded as default which should not.
For me, funny as it sounds, it helped just restarting eclipse...
This worked for me:
Remove all Mavin references in Environment Variables
Download the Binary from mavin
Unzip it to where you'd like ex: C:\apache-maven-3.6.0
Go to Environment variables and add to System variable path "C:\apache-maven-3.6.0\bin"
start command prompt as Administrator
check version with: mvn -v
CMD Result:
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T20:41:47+02:00)
Maven home: C:\apache-maven-3.6.0\bin..
I also faced the following Error in my system (Mac)
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
After doing some random browsing, I came across the link "http://maven.apache.org/install.html" that says "JAVA_HOME" should be set to "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre".
When I changed "JAVA_HOME" as stated above in ".bash_profile", "mvn" command started working but "javac -version" command stopped working.
When I typed "javac -version" command, I got the following error
Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/bin/javac" (-1)
Hence I rolled back my "JAVA_HOME" to "/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home" in ".bash_profile" and added the following line at the top in "mvn" script
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre
Now both "mvn" and "javac" commands worked properly, but after careful observation of the mvn script, I could not make the difference between the following commands
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java -classpath /Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar -Dclassworlds.conf=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin/m2.conf -Dmaven.home=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1 -Dlibrary.jansi.path=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin org.codehaus.plexus.classworlds.launcher.Launcher
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/bin/java -classpath /Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/boot/plexus-classworlds-2.6.0.jar -Dclassworlds.conf=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin/m2.conf -Dmaven.home=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1 -Dlibrary.jansi.path=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1/bin org.codehaus.plexus.classworlds.launcher.Launcher
In the above the first command caused the following error
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
while the second command worked fine.
Please Note that both the above paths have "java" command while one is from "jre" the other is from "jdk"
Other global variables are as following in ".bash_profile"
export M2_HOME=/Users/venkatarajeevmandava/Documents/Maven/apache-maven-3.6.1
export PATH=$PATH:$M2_HOME/bin
Was able to solve this issue by deleting the downloaded maven in my machine ( /Users/kkohli/Desktop/Personal/Code/Java/apache-maven-3.6.3 ) and re-downloading the binary version from the apache site. Did not modify any other bashprofile file etc ( My M2_HOME, JAVA_HOME etc are set inside my bashprofile)

Categories

Resources