I'm trying to switch maven from 2 to 3 (on Linux) using:
sudo update-alternatives --set mvn /path/to/maven3/bin/mvn
Anyway mvn -v still gives version 2, so I always have to execute /path/to/maven3/bin/mvn to use maven. How can I rebind the mvn command to the appropriate maven path?
Run:
sudo update-alternatives --config mvn
Then choose which version you want use.
Also check than which mvn is symbolic link to /etc/alternatives/mvn
which mvn
And then recreate symbolic link to point on new Maven version. And verify than environment variable MAVEN_HOME points to the right directory.
Set system property M2_HOME to path to the maven home.
Related
I tried building a custom Jenkins-Plugin using Maven. Here is the issue:
My project depends on org.kohsuke.args4j (https://github.com/kohsuke/args4j). I've added the dependency in my pom.xml-file.
<dependencies>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.kohsuke.args4j</groupId>
<artifactId>args4j-maven-plugin</artifactId>
<version>2.33</version>
</dependency>
</dependencies>
The Problem
Apparently, this project requires somehow the tools.jar executable - which cannot be found.
[ERROR] Failed to execute goal on project commit-pipeline-xml: Could not resolve dependencies for project com.siemens.plugins:commit-pipeline-xml:hpi:0.1: Could not find artifact jdk:tools:jar:5.0 at specified path /usr/local/java/jdk-14.0.2/../lib/tools.jar
For my installation (see next paragraph) the path is wrong anyways, but I cannot even find tools.jar in /usr/local/java/jdk-14.0.2/lib/tools.jar where I would expect this file. A ls -l on $JAVA_HOME/lib outputs some files (mostly *.so) but no tools.jar. Also find $JAVA_HOME -name "tools" exposes nothing.
Installation of the jdk
For building my project the I'm using docker with ubuntu 18.04 as base. The jdk gets installed by downloading the tar.gz from oracle.com and installing it using the commands:
mkdir -p /usr/local/java
cd /usr/local/java
tar xzvf "$JAVA_JDK_PATH"
ls -l ./jdk-$JAVA_JDK_VERSION/bin
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk-$JAVA_JDK_VERSION/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk-$JAVA_JDK_VERSION/bin/javac" 1
sudo update-alternatives --set javac "/usr/local/java/jdk-$JAVA_JDK_VERSION/bin/javac"
ls -ld /usr/bin/java*
ls -ld /etc/alternatives/java*
$JAVA_JDK_PATH denotes the path of the downloaded zip-file and $JAVA_JDK_VERSION the jdk-version to download.
Note: I assume the installation works, since I can typically build other maven projects.
How to I install the jdk in order to get the tools.jar file?
Apparently, this is not possible any more since JDK9, according to #Hans and this post.
Closed.
I am working on a Java project with Gradle Wrapper (gradlew). I use Ubuntu Linux as my OS. When I run "gradle" it runs, and gives me information. But when I run "gradlew", it outputs as:
No command 'gradlew' found, did you mean:
Command 'gradle' from package 'gradle' (universe)
gradlew: command not found"
I did my research, I have the JDK, and I did sudo apt-get install gradle. How can I fix it?
The error is:
gradlew clean jpackage
Output:
bash: gradlew: command not found...
Linux and macOS
As noted in the comments, just running
./gradlew
worked for me. Adding the ./ tells it to look in the current directory since it isn't in the path.
Windows PowerShell
.\gradlew
The Gradle wrapper needs to be built. Try running gradle wrapper --gradle-version 2.13.
Remember to change 2.13 to your Gradle version number. After running this command, you should see new scripts added to your project folder. You should be able to run the wrapper with ./gradlew build to build your code.
Please refer to this guide for more information: Building Java Projects with Gradle
Running this Bash command works for me by running chmod 755 gradlew as sometimes file properties changed upon moving from one OS to another (Windows, Linux and Mac).
If you are using Mac, try giving root access to gradlew by doing:
chmod +x ./gradlew
From Mac,
Nothing is working except the following command:
chmod 777 gradlew
Then
./gradlew
The same problem occurs to me...
I check the file wrx permissions with:
$ls -l ./gradlew -> -rw-rw-r-- (no execute permission)
So I use command $chmod +x ./gradlew and this problem is solved.
In addition to Suragch's answer:
Linux and macOS
./gradlew clean
Windows PowerShell
.\gradlew clean
Windows cmd
gradlew clean
You must have the Gradle wrapper available locally before using gradlew. To construct that
gradle wrapper # --gradle-version v.xy
Optionally, pass the Gradle version explicitly. This step produces the gradlew binary. And then you should be able to
./gradlew build
For Ubuntu (Linux) users:
Doing bash ./gradlew build works, but ./gradlew build does not work.
For me, the issue was it was on the NTFS file system, and Linux does not let you execute a script from NTFS.
Try moving the code from NTFS to a Linux partition. Then ./gradlew build should work.
If you are using Visual Studio Code with Flutter, you should find it in your app folder, under the android folder:
C:\myappFolder\android
You can run this in the terminal:
./gradlew signingReport
The first thing is you need to run the gradle task that you mentioned for this wrapper. Example:
gradle wrapper
After running this command, check your directory for the gradlew and gradlew.bat files. gradlew is the shell script file, and it can be used in Linux and macOS. gradlew.bat is the batch file for the Windows OS. Then run,
./gradlew build (Linux and Mac). It will work.
Issue: Couldn't find gradlew at path jenkins
In my case, within the Jenkins CI for flutter project, I have to first run the flutter build app command, and then it automatically generated a gradlew file. And the above issue is resolved.
I put this command in my Jenkins file:
flutter build apk
In a Flutter project, don't forget to go to 'android' folder with 'cd android'.
Then you can run a command like './gradlew build' or './gradlew clean' on it (macOS).
If the answer marked as correct does not work, it is because you need to identify yourself as a super user.
sudo gradle wrapper --gradle-version 2.13
It worked for me.
I faced the same issue, but after some tries I found
it was happening because I was trying to create build in Git Bash,
instead of CMD with system administrator access.
If you create build with a command prompt, run as administrator. Then the build will get created.
If you are trying to run this command for a Flutter app, then go to the android folder first by cd android. And then use the command, and it should work.
cd android
./gradlew signingReport
I use IntelliJ IDEA and in Windows in the terminal I type:
gradlew.bat run
It is working for me.
Instead of gradlew assembleRelease, use ./gradlew assembleRelease.
I had to do dos2unix * in my current folder to make it work.
Ubuntu
Error:
Command 'gradlew' not found, did you mean:
command 'gradle' from snap gradle (7.2)
command 'gradle' from deb gradle (4.4.1-13)
See 'snap info ' for additional versions.
Use this command:
./gradlew signingReport
I'm new to Ubuntu and Linux in general. I want to code in Java on my computer, but I'm having problems installing IntelliJ IDEA on Ubuntu. I have downloaded and extracted the file and for some reason renamed the folder to idea. I tried moving the folder to /usr/share/applications or something but I didn't have permission. I used sudo -i in terminal to gain permission but didn't manage to get out of root folder. Can anyone help me with a step by step way to move the folder, create a shortcut in the search bar or whatever it's called and install it properly?
Note: This answer covers the installation of IntelliJ IDEA. For an extended script, that covers more JetBrains IDEs, as well as help for font rendering issues, please see this link provided by brendan.
Furthermore, a manual Desktop Entry creation is optional, as newer versions of IntelliJ offer to create it on first startup.
I have my intellij int /opt folder. So what I do is:
Download Intellij
Extract intellij to /opt-folder: sudo tar -xvf <intellij.tar> -C /opt/ (the -C option extracts the tar to the folder /opt/)
Create a Desktop Entry File called idea.desktop (see example file below) and store it anywhere you want (let's assume in your home directory)
Move the idea.desktop from your home directory to /usr/share/applications: sudo mv ~/idea.desktop /usr/share/applications/
Now (in a lot) Ubuntu versions you can start the application after the GUI is restarted. If you don't know how to do that, you can restart your PC..
idea.desktop (this is for community edition version 14.1.2, you have to change the paths in Exec= and Icon= lines if the path is different for you):
[Desktop Entry]
Encoding=UTF-8
Name=IntelliJ IDEA
Comment=IntelliJ IDEA
Exec=/opt/ideaIC-14.1.2/bin/idea.sh
Icon=/opt/ideaIC-14.1.2/bin/idea.png
Terminal=false
StartupNotify=true
Type=Application
Edit
I also found a shell script that does this for you, here. The given script in the link installs Oracle Java 7 for you and gives you the choice between Community and Ultimate Edition. It then automatically downloads the newest version for you, extracts it and creates a desktop entry.
I have modified the scripts to fulfill my needs. It does not install java 8 and it does not ask you for the version you want to install (but the version is kept in a variable to easily change that). You can also update Intellij with it. But then you have to (so far) manually remove the old folder! This is what i got:
Edit2
Here is the new version of the script. As mentioned in the comments, breandan has updated the script to be more stable (the jetbrains website changed its behavior). Thanks for the update, breandan.
#!/bin/sh
echo "Installing IntelliJ IDEA..."
# We need root to install
[ $(id -u) != "0" ] && exec sudo "$0" "$#"
# Attempt to install a JDK
# apt-get install openjdk-8-jdk
# add-apt-repository ppa:webupd8team/java && apt-get update && apt-get install oracle-java8-installer
# Prompt for edition
#while true; do
# read -p "Enter 'U' for Ultimate or 'C' for Community: " ed
# case $ed in
# [Uu]* ) ed=U; break;;
# [Cc]* ) ed=C; break;;
# esac
#done
ed=C
# Fetch the most recent version
VERSION=$(wget "https://www.jetbrains.com/intellij-repository/releases" -qO- | grep -P -o -m 1 "(?<=https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/BUILD/)[^/]+(?=/)")
# Prepend base URL for download
URL="https://download.jetbrains.com/idea/ideaI$ed-$VERSION.tar.gz"
echo $URL
# Truncate filename
FILE=$(basename ${URL})
# Set download directory
DEST=~/Downloads/$FILE
echo "Downloading idea-I$ed-$VERSION to $DEST..."
# Download binary
wget -cO ${DEST} ${URL} --read-timeout=5 --tries=0
echo "Download complete!"
# Set directory name
DIR="/opt/idea-I$ed-$VERSION"
echo "Installing to $DIR"
# Untar file
if mkdir ${DIR}; then
tar -xzf ${DEST} -C ${DIR} --strip-components=1
fi
# Grab executable folder
BIN="$DIR/bin"
# Add permissions to install directory
chmod -R +rwx ${DIR}
# Set desktop shortcut path
DESK=/usr/share/applications/IDEA.desktop
# Add desktop shortcut
echo -e "[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application" -e > ${DESK}
# Create symlink entry
ln -s ${BIN}/idea.sh /usr/local/bin/idea
echo "Done."
Old Version
#!/bin/sh
echo "Installing IntelliJ IDEA..."
# We need root to install
[ $(id -u) != "0" ] && exec sudo "$0" "$#"
# define version (ultimate. change to 'C' for Community)
ed='U'
# Fetch the most recent community edition URL
URL=$(wget "https://www.jetbrains.com/idea/download/download_thanks.jsp?edition=I${ed}&os=linux" -qO- | grep -o -m 1 "https://download.jetbrains.com/idea/.*gz")
echo "URL: ${URL}"
echo "basename(url): $(basename ${URL})"
# Truncate filename
FILE=$(basename ${URL})
echo "File: ${FILE}"
# Download binary
wget -cO /tmp/${FILE} ${URL} --read-timeout=5 --tries=0
# Set directory name
DIR="${FILE%\.tar\.gz}"
# Untar file
if mkdir /opt/${DIR}; then
tar -xvzf /tmp/${FILE} -C /opt/${DIR} --strip-components=1
fi
# Grab executable folder
BIN="/opt/$DIR/bin"
# Add permissions to install directory
chmod 755 ${BIN}/idea.sh
# Set desktop shortcut path
DESK=/usr/share/applications/IDEA.desktop
# Add desktop shortcut
echo -e "[Desktop Entry]\nEncoding=UTF-8\nName=IntelliJ IDEA\nComment=IntelliJ IDEA\nExec=${BIN}/idea.sh\nIcon=${BIN}/idea.png\nTerminal=false\nStartupNotify=true\nType=Application" > ${DESK}
echo "Done."
You can also try my ubuntu repository: https://launchpad.net/~mmk2410/+archive/ubuntu/intellij-idea
To use it just run the following commands:
sudo apt-add-repository ppa:mmk2410/intellij-idea
sudo apt-get update
The community edition can then installed with
sudo apt-get install intellij-idea-community
and the ultimate edition with
sudo apt-get install intellij-idea-ultimate
JetBrains has a new application called the Toolbox App which quickly and easily installs any JetBrains software you want, assuming you have the license. It also manages your login once to apply across all JetBrains software, a very useful feature.
To use it, download the tar.gz file here, then extract it and run the included executable jetbrains-toolbox. Then sign in, and press install next to IntelliJ IDEA:
If you want to move the executable to /usr/bin/ feel free, however it works fine out of the box wherever you extract it to.
This will also make the appropriate desktop entries upon install.
Since Ubuntu 18.04 installing Intellij IDEA is easy! You just need to search "IDEA" in Software Center. Also you're able to choose a branch to install (I use EAP).
For earlier versions:
According to this (snap) and this (umake) articles the most comfortable ways are:
to use snap-packages (since versions IDEA 2017.3 & Ubuntu 14.04):
install snapd system. Since Ubuntu 16.04 you already have it.
install IDEA snap-package or even EAP build
to use ubuntu-make
(for Ubuntu versions earlier than 16.04 use apt-get command instead apt):
Add PPA ubuntu-desktop/ubuntu-make (if you install ubuntu-make from standard repo you'll see only a few IDE's):
$ sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make
Install ubuntu-make:
$ sudo apt update
$ sudo apt install ubuntu-make
install preffered ide (IDEA, for this question):
$ umake ide idea
or even ultimate version if you need:
$ umake ide idea-ultimate
I upgrade Intellij IDEA via reinstalling it:
$ umake -r ide idea-ultimate
$ umake ide idea-ultimate
TL;DR:
Download IntelliJ IDEA from here.
cd Downloads
extract the downloaded file: sudo tar xf ideaIC-2017.2.5.tar.gz -C /opt/
Switch to the bin directory: cd /opt/idea-IC-172.4343.14/bin
Run idea.sh from the bin subdirectory.
Since Ubuntu 16.04 includes snapd by default.
So, the easiest way to install the stable version is
IntelliJ IDEA Community:
$ sudo snap install intellij-idea-community --classic
IntelliJ IDEA Ultimate:
$ sudo snap install intellij-idea-ultimate --classic
For the latest version use channel --edge
$ sudo snap install intellij-idea-community --classic --edge
Here is the list of all channels https://snapcraft.io/intellij-idea-ultimate (drop down 'All versions').
options
--classic
The --classic option is required because the IntelliJ IDEA snap requires full access to the system, like a traditionally packaged application.
[https://www.jetbrains.com/help/idea/install-and-set-up-product.html#install-on-linux-with-snaps]
--edge
--edge Install from the edge channel
[http://manpages.ubuntu.com/manpages/bionic/man1/snap.1.html]
Note: Snap, also work a few major distributions: Arch, Debian, Fedora, openSUSE, Linux Mint,...
Recent IntelliJ versions allows automatic creation of desktop entry. See this gist
Launch from commandline. If launching for the first time, setup will ask about creating a desktop launcher icon; say yes. Or else after launching (ie. from the commandline) any time, use the IDEA menu Configure > Create Desktop Entry . That should create /usr/share/applications/intellij-idea-community.desktop
Trigger the Ubuntu desktop search (ie. Windows key), find the Intellij IDEA you used to create the desktop entry.
Drag the icon it's showing into the Ubuntu Launcher.
In a simple manner you can also try to just run a pre-packaged docker with intellij, I found the good job of #dlsniper : https://hub.docker.com/r/dlsniper/docker-intellij/
you just need to have docker installed and to run :
docker run -tdi \
--net="host" \
--privileged=true \
-e DISPLAY=${DISPLAY} \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v ${HOME}/.IdeaIC2016.1_docker:/home/developer/.IdeaIC2016.1 \
-v ${GOPATH}:/home/developer/go \
dlsniper/docker-intellij
Standalone installation
Download the tarball.tar.gz.
Extract the tarball to a directory that supports file execution.
For example, to extract it to the recommended /opt directory, run the following command:
sudo tar -xzf ideaIC-2020.3.tar.gz -C /opt
Go to /opt folder and open intellij folder
Go to /bin folder and execute the command sh idea.sh
Now the application opened and create the desktop shortcut if you need
I find and follow this youtube:
https://www.youtube.com/watch?v=PbW-doAiAvI
Basically, download the tar.gz package, extract into /opt/, and then run the "idea.sh" under bin folder (i.e. /opt/idea-IC-163.7743.44/bin/idea.sh)
Enjoy
I needed to install various JetBrains tools on a number of machines from CLI, so I wrote a tiny tool to help with that. It also uses cleaner APIs from JB making it hopefully more stable, and works for various JB tools.
Feel free to try it: https://github.com/MarcinZukowski/jetbrains-installer
try simple way to install intellij idea
Install IntelliJ on Ubuntu using Ubuntu Make
You need to install Ubuntu Make first. If you are using Ubuntu 16.04, 18.04 or a higher version, you can install Ubuntu Make using the command below:
sudo apt install ubuntu-make
Once you have Ubuntu Make installed, you can use the command below to install IntelliJ IDEA Community edition:
umake ide idea
To install the IntelliJ IDEA Ultimate edition, use the command below:
umake ide idea-ultimate
To remove IntelliJ IDEA installed via Ubuntu Make, use the command below for your respective versions:
umake -r ide idea
umake -r ide idea-ultimate
you may visit for more option.
https://itsfoss.com/install-intellij-ubuntu-linux/
I have this line of code in a project in eclipse & it's giving me error.
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File(System.getenv("MAVEN_HOME"))); //giving error
So I ran and its giving blank line as output
echo $MAVEN_HOME
However, I am able to run other maven projects through command prompt and through eclipse.
I have following question..
Q 1. what is the difference between the following two commands
whereis maven
maven: /etc/maven /usr/share/maven
& when I run
whereis mvn
mvn: /usr/bin/mvn /usr/bin/X11/mvn /usr/share/man/man1/mvn.1.gz
Q 2. what do I need to put in .bashrc... please tell me exactly...
this is my current content of .bashrc file
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
export JAVA_HOME
export PATH
EDIT
mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_65, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-amd64/jre
Thanks :)
Just to use in eclipse you can add this in Window -> Preferences -> Java -> Build Path -> Classpath Variables.
Just add new variable with name MAVEN_HOME.
But for executions you need to set in in Run/Debug configuration - probably that's what you need.
whereis maven
is about directory, and
whereis mvn
is about executable file.
For .bashrc:
MAVEN_HOME=/usr/share/maven
export MAVEN_HOME
Don't set the MAVEN_HOME in bashrc file but set it in the Environment tab of the launcher configuration of Eclipse.
The .bashrc file is for the bash environment
Basically invoker.setMavenHome(MAVEN_HOME); this needs the home directory where you have installed maven. If you need to find where is the home directory of maven. You can you use following approaches as you tried.
whereis maven
This will be showing where is the location which maven has been installed into your computer.
maven: /etc/maven /usr/share/maven
I am new to hadoop and maven. I will like to compile the hadoop 2.0.3 from the source and install it. I am following instructions from
http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/SingleCluster.html
So far, i have managed to download hadoop source code and from the source directory issued "mvn clean install -Pnative"
Next i tried to execute mvn assembly:assembly, but i get following error:
Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.3:assembly (default-cli) on project hadoop-main: Error reading assemblies: No assembly descriptors found. -> [Help 1]
Please help so that i can move forward.
Also, the above mentioned install link, does not mention what should be the value of "$HADOOP_COMMON_HOME/$HADOOP_HDFS_HOME"
I compiled 1.0.4 just as an academic exercise. Not sure if it will be valid for 2.0.3
This should be done (on Ubuntu) before you start compilation to make sure that all needed stuff is there:
sudo apt-get -y install maven build-essential protobuf-compiler autoconf automake libtool cmake zlib1g-dev pkg-config libssl-dev
I did not had subversion so I did this too:
sudo apt-get install subversion
After that I checked out the code:
svn checkout http://svn.apache.org/repos/asf/hadoop/common/tags/release-1.0.4/ hadoop-common-1.0.4
Then went to newly created folder “hadoop-common-1.0.4″ and gave command:
ant clean package
You can refer to my blog for the whole story:
http://hadoopmagic.wordpress.com/