How to install maven with brew but without openjdk? - maven

I already have Java HotSpot JDK 11 on my machine that I'm using for everything.
When I typed brew install maven it tried to install openjdk as a dependency. I don't want that and want maven to use my JDK, not its own openjdk.
So, how can I tell it to not install openjdk?

After installing java, I have installed Maven with command
brew install --ignore-dependencies maven
It worked for me, for Gradle also.

The way I solved it was installing the openjdk with brew (in my case openjdk#8). Mine was different from the default one that brew requires by default. So after that I created a symlink to my openjdk where maven is expecting to find the SDK. And finally installed maven without dependencies.
brew install openjdk#8
cd /usr/local/opt
ln -s ../Cellar/openjdk#8/1.8.0+275 openjdk
brew install --ignore-dependencies maven

I don't think there is a supported way to not install a dependency from the command line. However, you can configure the installed mvn to use another JDK. It requires two steps:
Add /usr/local/opt/maven/libexec/bin to your $PATH before /usr/local/bin to pick up the mvn script that does not override $JAVA_HOME
Set $JAVA_HOME in your environment or .mavenrc to pick up the your preferred version of Java

or (building on what Enrique Cordero said above) to re-use an already installed AdoptOpenJDK 8:
brew install adoptopenjdk8
cd /usr/local/opt
ln -s ../Caskroom/adoptopenjdk8/8,275:b01 ./openjdk
brew install maven --ignore-dependencies
and then remove the symlink
rm /usr/local/opt/openjdk

Not exactly the answer for the asked question, but if someone wants to change the JDK path from the default openjdk to the system defined JDK, one can do the following:
First, brew install maven - this will install maven (and openjdk) on the mac and point the default JDK used by maven to be this openjdk
Second, set JAVA_HOME in your ~/.bashrc or ~/.zshrc to point to sytem installed JDK
# set JAVA_HOME for mvn
export JAVA_HOME=`/usr/libexec/java_home`

Related

How to install specific version of cmake on mac?

I try to install an old version of cmake. I install .dmg file from here.
But I couldn't use on terminal via cmake xxx. I know that I install for command line using brew install cmake. But it installs the latest version. How can I install a specific version?

Finding JDK after installing Java via PPA repository

Where do I find the java JDK after installing it via PPA repository in Linux Mint? I followed this to install it:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo update-java-alternatives -s java-8-oracle
Running java and javac work, showing version java version "1.8.0_101". Running whereis shows both binaries at /usr/bin/ folder. Running printenv JAVA_HOME shows me the /usr/ directory (I set it by hand, I assumed that was the proper folder).
When I run NetBeans, though, it cant find the jdkhome. I've changed netbeans.conf to have netbeans_jdkhome="/usr/", and I also tried running with the --jdkhome /usr/ option, but to no avail.
What directory should be the JDK home after installing Java the way I have? Or how do I find it?
Checkout ls -l /usr/bin/java to see where does the symbolic link point to.
Or you can also try:
update-alternatives --all | grep java

How to install specific version of maven in mac using brew command

I want to install specific version (3.0.5) of maven in my using brew command. I tried the following command which is failed with Error: No available formula with the name "3.0.5"
brew install maven 3.0.5
Any ideas?
brew search maven
lists all maven versions as below
maven maven-completion maven-shell maven#3.0 maven#3.1 maven#3.2 ✔ maven#3.3
brew install maven#3.0
Installs maven 3.0.5 on my mac.
brew install https://raw.github.com/Homebrew/homebrew-versions/master/maven30.rb
it will then use a different Homebrew's formular which will give you the maven 3.0.5 instead
I tried this last on my Mac and it works installing the 3.0.5!
If none works and you can use similar version try the below:
brew install maven30
What OS do you have? On OS X 10.9 you should use brew install maven30 since maven 3.1.1 seems to be buggy.
By the way:
Using Homebrew:
you#host:~$ brew install maven will install Maven 3.3.1 (3/24/15)
you#host:~$ brew install maven30 will install Maven 3.0 which should be
better
If you got a 404 error, try doing a brew update just before.
If always nothing, try to recover the installation:
cd ~/Documents
mkdir BrewRecovery
cd BrewRecovery
curl -OL https://gist.githubusercontent.com/ilovezfs/21a741a78927a17b9ad1/raw/fef5866ccd51f07a9635fcb1096e8df0479af01b/Brewfile-deanchester.brewfile
md5 Brewfile-deanchester.brewfile
In general,
brew is unable to install any specific version such as 3.8.1
as it only gives few versions as the available options.
The only way then to install would be do it manually.
Also don't forget to update Path variable in your mac.
If you run brew install maven, the latest stable version would be installed.
If you want to install the previous versions you can run
brew install maven#versionNumber where versionNumber is your desired version.
Not all versions are available here in,
Also you may try hitting the website with the required version and download the file its available
https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/.
where you may substitute 3.6.1 with the version you want to run.

can not install mvn 3.3.3 on ubuntu 14.04

I am using Ubuntu 14.04. I need to run mvn 3.3.3. Currently, the installed mvn version 3.0.5. When I enter
sudo apt-get install maven
it says
maven is already the newest version
is there a way to force install mvn 3.3.3?
Add a ppa containing maven 3.3.3, for example this one by executing these instructions on the command-line:
sudo apt-get purge maven maven2 maven3
sudo add-apt-repository ppa:andrei-pozolotin/maven3
sudo apt-get update
sudo apt-get install maven3
If you are not comfortable with a PPA (personal package archive) where you have no assurance of the provenance this is an alternative.
From a security perspective if you don't know where it came from don't install it.
In my linked article I retrieve the latest file from apache which is a known and trusted source. You can get the latest version
\#identify the latest version of maven
latest=$(curl http://www-us.apache.org/dist/maven/maven-3/ | tac | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,3\}[0-9]\).*/\1/p' | head -1)
\#download it
wget http://www-us.apache.org/dist/maven/maven-3/$latest/binaries/apache-maven-$latest-bin.tar.gz
then install it from
\#Unpack it
sudo tar -zxf apache-maven-$latest-bin.tar.gz -C /usr/local/
\#create a sym link to it
sudo ln -s /usr/local/apache-maven-$latest/bin/mvn /usr/bin/mvn
as outlined in the link above.
I just installed maven 3.2.5.
To do that I downloaded the version I wanted as noted.
Unzipped using: tar -xvf apache-maven-3.2.5-bin.tar.gz
to: /opt/ and let p7zip do its thing.
Then in the terminal I did the following:
Check environment variable value:
echo $JAVA_HOME
Adding to PATH:
export PATH=/opt/apache-maven-3.2.5/bin:$PATH
typed: mvn -v
reviewed the output
For me the above worked fine.

How can I install Apache Ant on Mac OS X?

I tried to install Apache Ant on my Mac and I followed the next steps :
I downloaded apache-ant-1.8.1-bin.tar.gz into my Downloads folder.
I moved the file to /usr/local/ using this commands : sudo sh and mv apache-ant-1.8.1-bin.tar.gz /usr/local/
Now I want to use cd /usr/local/ but it's not working, I get back "No such file or directory".
Then I used cd /usr/ and ls commands and it seems that the local folder is there. If I try to access it I get the same error.
Since I already used sudo su why I can't access it? Any ideas?
Ant is already installed on some older versions of Mac OS X, so you should run ant -version to test if it is installed before attempting to install it.
If it is not already installed, then your best bet is to install Homebrew (brew install ant) or MacPorts (sudo port install apache-ant), and use those tools to install Apache Ant.
Alternatively, though I would highly advise using Homebrew or MacPorts instead, you can install Apache Ant manually. To do so, you would need to:
Decompress the .tar.gz file.
Optionally put it somewhere.
Put the "bin" subdirectory in your path.
The commands that you would need, assuming apache-ant-1.8.1-bin.tar.gz (replace 1.8.1 with the actual version) were still in your Downloads directory, would be the following (explanatory comments included):
cd ~/Downloads # Let's get into your downloads folder.
tar -xvzf apache-ant-1.8.1-bin.tar.gz # Extract the folder
sudo mkdir -p /usr/local # Ensure that /usr/local exists
sudo cp -rf apache-ant-1.8.1-bin /usr/local/apache-ant # Copy it into /usr/local
# Add the new version of Ant to current terminal session
export PATH=/usr/local/apache-ant/bin:"$PATH"
# Add the new version of Ant to future terminal sessions
echo 'export PATH=/usr/local/apache-ant/bin:"$PATH"' >> ~/.profile
# Verify new version of ant
ant -version
For MacOS Maveriks (10.9 and perhaps later versions too), Apache Ant does not come bundled with the operating system and so must be installed manually. You can use brew to easily install ant. Simply execute the following command in a terminal window to install brew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It's a medium sized download which took me 10min to download and install. Just follow the process which involves installing various components. If you already have brew installed, make sure it's up to date by executing:
brew update
Once installed you can simply type:
brew install ant
Ant is now installed and available through the "ant" command in the terminal.
To test the installation, just type "ant -version" into a terminal window. You should get the following output:
Apache Ant(TM) version X.X.X compiled on MONTH DAY YEAR
Source: Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova
If you are getting errors installing Brew, try uninstalling first using the command:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
Thanks to OrangeDog and other users for providing additional information.
If you have MacPorts installed (https://www.macports.org/), do this:
sudo port install apache-ant
If you're a homebrew user instead of macports, homebrew has an ant recipe.
brew install ant
To get Ant running on your Mac in 5 minutes, follow these steps.
Open up your terminal.
Perform these commands in order:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install ant
If you don't have Java installed yet, you will get the following error: "Error: An unsatisfied requirement failed this build."
Run this command next: brew cask install java to fix this.
The installation will resume.
Check your version of by running this command:
ant -version
And you're ready to go!
Use Brew is always good way to install ANT and other needs.
To install type below command on terminal.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
after Brew installation , type
brew install ant
This will install Ant on your system. Also you will not need to worry about setting up the path.
Also i have documented on the same - How to Install ANT on Mac OS?
The only way i could get my ant version updated on the mac from 1.8.2 to 1.9.1 was by following instructions here
http://wiki.eclipse.org/Ant/User_Guide
MacPorts will install ant for you in MacOSX 10.9. Just use
$ sudo port install apache-ant
and it will install.

Resources