I was trying to change M2_HOME in bash_profile to configure a new version of Maven. Earlier, it was set to 2.2.1. Now I'm trying to change the path to 3.3.3. This is my bash_profile
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
export M2_HOME=/usr/local/apache-maven-3.3.3
#export M2_HOME=/usr/local/apache-maven-2.2.1
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:$M2_HOME/bin
export CATALINA_HOME=/Library/Tomcat/apache-tomcat-7.0.68
When I try to run source ~/.bash_profile and then mvn -version I get the following error -
$mvn -version
Error: Could not find or load main class org.codehaus.classworlds.Launcher
Any suggestions to solve this please?
PS: I'm on OS X El Captain
A simpler alternative is to set up some bash aliases. I have added the following to my ~/.bash_profile for switching between maven versions and Java versions:
export BASE_PATH=$PATH
#alias java5="export JAVA_HOME=`/usr/libexec/java_home -v1.5 -a x86_64 -d64`"
alias java6="export JAVA_HOME=`/usr/libexec/java_home -v1.6`"
alias java7="export JAVA_HOME=`/usr/libexec/java_home -v1.7`"
alias java8="export JAVA_HOME=`/usr/libexec/java_home -v1.8`"
# maven versions
alias m30="PATH=~/tools/apache-maven-3.0.5/bin:$BASE_PATH"
alias m31="PATH=~/tools/apache-maven-3.1.1/bin:$BASE_PATH"
alias m32="PATH=~/tools/apache-maven-3.2.5/bin:$BASE_PATH"
alias m33="PATH=~/tools/apache-maven-3.3.9/bin:$BASE_PATH"
Note the use of /usr/libexec/java_home for setting up JAVA_HOME which is similar to linux alternatives for switching java versions.
So, in a new terminal session the following:
[steve#steves-mbp ~]$ java8
[steve#steves-mbp ~]$ m33
[steve#steves-mbp ~]$
sets me up to use maven 3.3 and Java 8.
Please also take into account the comment by ~khmarbaise regarding M2_HOME and forget that this environment variable exists.
Add a new symlink for mvn3 worked for me
ln -s /usr/local/apache-maven-3.3.3/bin/mvn /usr/local/User/bin/mvn3
It is common, particularly in an environment where a product portfolio is quite large, to have to support multiple Maven versions. Similar to having to support multiple Java versions, you can create a script that will track and modify your environment accordingly. I use a Mac, so the notion of a jEnv type of mechanism is what I use for Java. On Windows, a similar concept can be used although It would take some coding to properly adjust the path settings.
Here's a /usr/local/bin/mvnEnv bash script that I use to quickly change my Maven runtime. It's not nearly as comprehensive as jEnv, but it works for me so perhaps it can work for you. Adjust the various parameters to conform to your various Maven installs and update your PATH appropriately, if on Windows. (I know you're using a Mac, so the Windows comment is for others that may have this issue on Windows.)
Just update your ~/.bash_profile to call this script with the appropriate parameters if you need a default. Then, when you need a different version of Maven, you can just execute the script like
mvnEnv v33
And voila, you've just quickly changed your Maven version! If you don't know what versions of Maven are supported, simply execute the mvnEnv command and a list of valid versions will be printed. You will, however, have to add any new versions of Maven to the script for the new version to be available.
#!/bin/bash
echo "Setting the maven implementation version"
v22=/usr/local/Cellar/maven2/2.2.1/libexec/bin/mvn
v30=/usr/local/Cellar/maven30/3.0.5/libexec/bin/mvn
v31=/usr/local/Cellar/maven31/3.1.1/libexec/bin/mvn
v32=/usr/local/Cellar/maven32/3.2.5/libexec/bin/mvn
v33=/usr/local/Cellar/maven/3.3.9/libexec/bin/mvn
if [ -e /usr/local/bin/mvn ]
then
echo "Remove the maven soft link."
sudo rm /usr/local/bin/mvn
else
echo "Maven soft link could not be found."
fi
maven=$v22
if [ $# == 0 ] || [ -z "${!1// }" ]
then
echo "No Arguments supplied, using default $maven"
echo "Available versions:"
echo " v22 = 2.2.1"
echo " v30 = 3.0.5"
echo " v31 = 3.1.1"
echo " v32 = 3.2.5"
echo " v33 = 3.3.9"
elif [ -e ${!1} ]
then
echo "Setting maven to use ${!1} via $1"
maven=${!1}
else
echo "Using the default maven setting, provided argument [$1] is not recognized."
fi
echo "Creating new soft link to $maven";
sudo ln -s $maven /usr/local/bin/mvn
Related
Running Debian Stretch on an r710. Using the non-free/contrib build for driver support.
When I try to use packages that I've installed (curl, zpool, etc), I have to include the path to the package... Which is a pain when I don't always know where packages install to.
Two questions:
How do I remedy the path issue in the short term?
How do I amend Debian so that when packages are installed, their paths update/install automatically?
Just install it by:
apt install curl
or sudo apt install curl
Find where the command is stored by
which <command>
Either you can try run curl from the output above for example /usr/bin/curl then try execute this:
/usr/bin/curl
For a temporary fix until you solve the real problem you can do:
cd /usr/local/bin; ln -s $(which curl) curl
Or you can just set an alias:
echo "alias curl='$(which curl)'" >> ~/.bashrc; . ~/.bashrc
Troubleshoot your problem:
Check so PATH folder has the correct paths exported:
printf "%s\n" $PATH
Modify current PATH
Use the export command to add new paths and see if that works you can then update your ~/.bashrc or ~/.bash_profile, but first you can try in shell without adding it permanent to $PATH
export PATH=$PATH:/missed/bin/folder
To format your PATH variable for easy viewing in future you can add below function to your .bashrc
function path(){
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}
I am new to the oracle apps form development.
i am unable to generate .FMX file using below command in putty.
frmcmp_batch.sh module=/u01/install/APPS/apps/apps_st/appl/au/12.0.0/forms/US/EMP.fmb
userid=apps/apps
output_file=/u01/install/APPS/apps/apps_st/appl/po/12.0.0/forms/US/EMP.fmx module_type=form
Please help me on the same.
Thanks&Regards,
Vivek
you may call a script from the command line
$ appCompile.sh EMP.fmb
where appCompile.sh maybe like below one
ORACLE_HOME=/u01/install/APPS/apps/apps_st/appl/au/12.0.0/forms/US; export ORACLE_HOME
export NLS_LANG=american_america.we8iso8859p9 #for Turkish
NLS_DATE_FORMAT=DD/MM/YYYY; export NLS_DATE_FORMAT
FORMS_PATH=/data/aski_kodlar/standard; export FORMS_PATH
alias oh='cd $ORACLE_HOME'
LD_LIBRARY_PATH=/u01/install/APPS/apps/apps_st/appl/au/12.0.0/forms/US/lib:/u01/install/APPS/apps/apps_st/appl/au/12.0.0/forms/US/jdk/jre/lib/sparcv9:
/u01/install/APPS/apps/apps_st/appl/au/12.0.0/forms/US/jdk/jre/lib/sparcv9/server:/u01/install/APPS/apps/apps_st/appl/au/12.0.0/forms/US/jdk/jre/lib/sparcv9/native_threads
export LD_LIBRARY_PATH
export ORACLE_TERM=vt220
export TERM=xterm
type=$2
if test "$type" = ""
then
type=form
fi
echo Compiling Form $1 ....
filename=`echo $1|cut -f1 -d.`
/u01/install/APPS/apps/apps_st/appl/scripts/frmcmp_batch.sh userid=apps/apps#db_name Module_Type=$type compile_all=yes window_state=minimize batch=yes Module=$1
Before compile you must SET the environment variables in linux, it depends on which kind of environment you are logged in, if it is Oracle On-Demand or Custom.
For custom:
Search a file extension .env
Usually located in /u01/oracle/EBS/app, run that file to SET environment variables.
For Oracle On-Demand:
In Linux SSH, run comand below where XXXX is the database
pbrun impdba -u apXXXX
Afer that you must run your compleation script.
Put your promp in
cd $AU_TOP/forms/US
export PATH=$PATH:$AU_TOP/resource:$AU_TOP/forms/US
Run compilation script by replacing APPS_PASSWORD, XXCUST_TOP, XX_FORM_FILE.
frmcmp_batch module=$XXHMS_TOP/forms/US/XX_FORM_FILE.fmb userid=apps/APPS_PASSWORD output_file=$XXCUST_TOP/forms/US/XX_FORM_FILE.fmx compile_all=special batch=yes
It will create a LOG file with .err extension.
this would help :
frmcmp_batch module=/disk5/PROD/apps/apps_st/appl/au/12.0.0/forms/US/EMP.fmb userid=apps/apps output_file=/disk5/PROD/apps/apps_st/appl/ont/12.0.0/forms/US/EMP.fmx module_type=form batch=yes
The starting situation
I have a Jenkins build Project where I'm doing almost everything by calling my build script (./jenkins.sh). I'm building a Cordova Project, which is dependent on certain versions of Node and Xcode. I'm running the builds on Macs with the latest MacOS Sierra.
So far I'm setting the environment variables in the Jenkins Build with the EnvInject Plugin(https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin):
The Goal
I want to have the environment variables also set by the build script instead of in the Jenkins Build. This way the environment variables are also in version control and I don't have to touch the Jenkins Build itself.
Basically I need to rebuild the logic of the EnvInject Plugin with bash.
What I've tried #1
Within my jenkins.sh build script I've set the environment variables with export
jenkins.sh:
#!/bin/bash -ve
nodeVersion=7.7.8
xcodeVersion=8.3.1
androidSDKVersion=21.1.2
export DEVELOPER_DIR=/Applications/Xcode_${xcodeVersion}.app/Contents/Developer
export ANDROID_HOME=/Applications/adt/sdk
export PATH=/usr/local/Cellar/node/${nodeVersion}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/usr/local/bin:/Applications/adt/sdk/tools:/usr/local/bin/:/Applications/adt/sdk/build-tools/${androidSDKVersion}:$PATH
# print info
echo ""
echo "Building with environment Variables"
echo ""
echo " DEVELOPER_DIR: $DEVELOPER_DIR"
echo " ANDROID_HOME: $ANDROID_HOME"
echo " PATH: $PATH"
echo " node: $(node -v)"
echo ""
This yields:
Building with environment Variables
DEVELOPER_DIR: /Applications/Xcode_8.3.1.app/Contents/Developer
ANDROID_HOME: /Applications/adt/sdk
PATH: /usr/local/Cellar/node/7.7.8/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/usr/local/bin:/Applications/adt/sdk/tools:/usr/local/bin/:/Applications/adt/sdk/build-tools/21.1.2:/Users/mles/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin
node -v
node: v0.10.48
PATH, DEVELOPER_DIR, ANDROID_HOME seems to be set correctly, however it is still using the system version of node v0.10.48 instead of v7.7.8 as set in PATH.
What I've tried #2
I've sourced the variables:
jenkins.sh:
#!/bin/bash -ve
source config.sh
# print info
echo ""
echo "Building with environment Variables"
echo ""
echo " DEVELOPER_DIR: $DEVELOPER_DIR"
echo " ANDROID_HOME: $ANDROID_HOME"
echo " PATH: $PATH"
echo " node: $(node -v)"
echo ""
config.sh
#!/bin/bash -ve
# environment variables
nodeVersion=7.7.8
xcodeVersion=8.3.1
androidSDKVersion=21.1.2
export DEVELOPER_DIR=/Applications/Xcode_${xcodeVersion}.app/Contents/Developer
export ANDROID_HOME=/Applications/adt/sdk
export PATH=/usr/local/Cellar/node/${nodeVersion}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/usr/local/bin:/Applications/adt/sdk/tools:/usr/local/bin/:/Applications/adt/sdk/build-tools/${androidSDKVersion}:$PATH
The result was the same as in What I've tried #1: Still using system node v0.10.48 instead of node v7.7.8
The question
How can I set the PATH, DEVELOPER_DIR, ANDROID_HOME environment variables properly to be used only within the build script?
#tripleee
Above I'm determining node by calling node: $(node -v). In the build script I'm running gulp which triggers Ionic / Apache Cordova. Do the brackets around node -v start a subshell which has it's own environment variables?
#Jacob
We have used nvm before, but we want to have less dependencies. Using nvm requires to install nvm on all build machines. We have a standard of installing node with brew. That's why I'm using /usr/local/Cellar/node/${nodeVersion} as path to node.
#Christopher Stobie
env:
jenkins#jenkins:~$ env
MANPATH=/Users/jenkins/.nvm/versions/node/v6.4.0/share/man:/usr/local/share/man:/usr/share/man:/Users/jenkins/.rvm/man:/Applications/Xcode_7.2.app/Contents/Developer/usr/share/man:/Applications/Xcode_7.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man
rvm_bin_path=/Users/jenkins/.rvm/bin
NVM_CD_FLAGS=
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/t0/h77w7t2s1fx5mdnsp8b5s6y00000gn/T/
SSH_CLIENT=**.**.*.** ***** **
NVM_PATH=/Users/jenkins/.nvm/versions/node/v6.4.0/lib/node
SSH_TTY=/dev/ttys000
LC_ALL=en_US.UTF-8
NVM_DIR=/Users/jenkins/.nvm
rvm_stored_umask=0022
USER=jenkins
_system_type=Darwin
rvm_path=/Users/jenkins/.rvm
rvm_prefix=/Users/jenkins
MAIL=/var/mail/jenkins
PATH=/Users/jenkins/.nvm/versions/node/v6.4.0/bin:/Users/jenkins/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/jenkins/.rvm/bin:/Users/jenkins/tools/oclint/bin:/Applications/adt/sdk/tools:/Applications/adt/sdk/platform-tools:/Applications/adt/sdk/build-tools/android-4.4:/Users/jenkins/.rvm/bin
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/dist
rvm_loaded_flag=1
PWD=/Users/jenkins
LANG=en_US.UTF-8
_system_arch=x86_64
_system_version=10.12
rvm_version=1.26.10 (latest)
SHLVL=1
HOME=/Users/jenkins
LS_OPTIONS=--human --color=always
LOGNAME=jenkins
SSH_CONNECTION=**.**.*.** ***** **.**.*.** **
NVM_BIN=/Users/jenkins/.nvm/versions/node/v6.4.0/bin
NVM_IOJS_ORG_MIRROR=https://iojs.org/dist
rvm_user_install_flag=1
_system_name=OSX
_=/usr/bin/env
alias:
jenkins#jenkins:~$ alias
alias l='ls -lAh'
alias rvm-restart='rvm_reload_flag=1 source '\''/Users/jenkins/.rvm/scripts/rvm'\'''
This doesnt look like an environment variable issue. It looks like a permissions issue. The user executing the script is either:
not able to read the /usr/local/Cellar/node/7.7.8/bin directory, or
not able to read the node executable from that directory, or
not able to execute the node executable from that directory
In order to test, become that user on the machine and execute the node command against the full path:
/usr/local/Cellar/node/7.7.8/bin/node -v
or, if you need to, change the script to avoid using PATH lookups (Im suggesting this for diagnosis only, not as a solution):
echo " node: $(/usr/local/Cellar/node/7.7.8/bin/node -v)"
If you are still at a loss, try this line:
echo " node: $(sh -c 'echo $PATH'; which node)"
I am writing a little shell script to help setup a production/development environment for some of our software and part of it requires subversion.
I need a way to check if subversion is installed on a *nix(usually mac) machine.
I was thinking of checking if export SUBVERSION_HOME=/opt/subversion exists in .profile since that is what the devs use here, but are there any more concrete ways?
You could do something crude:
which svn
In a test:
if [[ -n $(which svn) ]]; then
# do something
fi
Caveat: this would fail in the very unlikely even that someone has a svn installed that is not actually Subversion.
Something simple like this maybe?
which svn > /dev/null
if [ $? -eq 1 ]; then
echo "subversion is not installed"
exit 1
fi
I have installed sun-java in archlinux kde by first building the package and then installing it. This is the way the environment variables are set in my machine:
file: /etc/profile
# /etc/profile
#Set our umask
umask 022
# Set our default path
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin"
export PATH
# Load profiles from /etc/profile.d
if test -d /etc/profile.d/; then
for profile in /etc/profile.d/*.sh; do
test -r "$profile" && . "$profile"
done
unset profile
fi
# Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then
. /etc/bash.bashrc
fi
# Termcap is outdated, old, and crusty, kill it.
unset TERMCAP
# Man is much better than us at figuring this out
unset MANPATH
and file: /etc/profile.d/jdk.sh
export J2SDKDIR=/opt/java
export PATH=$PATH:/opt/java/bin:/opt/java/db/bin
export JAVA_HOME=/opt/java
export DERBY_HOME=/opt/java/db
what I understand from this is, jdk path should be set in the path environment variable but its not. But the attribute $JAVA_HOME is set correctly. Any reasons why am I facing this problem?
/etc/profile and /etc/profile.d are processed only for login shells, so unless you're doing ssh into the machine where java is installed you won't get those variables.
To have them locally (e.g. when you open an xterm on a workstation) put them in the file /etc/bash.bashrc.
Hope this helps.
Actually, it was a silly mistake on my part. I am using zsh shell. So I was required to put:
export PATH=$PATH:$JAVA_HOME/bin
in .zshrc file instead of .bashrc.