When I am running mvn clean install for my build on linux RHEL 6. I'm getting the following error: java.lang.outOfMemoryError heap space.
I have read all the articles on internet. On my machine I dont have a file called mvn.sh, I only have a file mvn.bat.
Where can I set the export MAVEN_OPTS command?
You can run the mvn command, so its irrelevant wether you are using a .sh or .bat file. For future reference you should keep in mind though that .bat files are for Windows, not Linux. Anyway, in the same shell you are running your mvn command in, do this first:
export MAVEN_OPTS="-Xmx512M"
Then execute your mvn command. Bump the number up if you still run out of memory.
When I am running mvn clean install for my build on linux RHEL 6 it is showing java.lang.outOfMemoryError heap space.
You need to set the MAVEN_OPTS environment variable.
I have read all the articles on internet
That is false. At best you have read a TINY FRACTION of the relevant articles.
... and in my machine I don't have mvn.sh, I have mvn.bat
If you have used "yum" to install Maven, then there will be a "mvn" command on your command path. On my system, it is a shell script. If you were going to "hack" a script, that would what you would edit.
But you shouldn't need to.
and where to set export MAVEN_OPTS COMMAND.
This is a very basic "How to use a Linux command shell" question.
The answer is either you type is at the command prompt before you run the "mvn" command, or you add it to your shell initialization file and restart the shell as appropriate.
My advice would be to invest some time in reading a tutorial about how to use the Linux command shell. It will save you a lot of time in the long term.
Related
I have azure-cli installed in my mac and I can successfully execute all azure commands from cli. I want to do the same from a java application. I have seen examples of using REST endpoints and azure-sdk-for-java. But what I want is to execute the azure-cli commands directly from java.
I tried running 'azure login' from a java program, but I got the following error.
Cannot run program "azure": error=2, No such file or directory
The problem is in a lack of your PATH variable. If you want to enjoy the same "find the command" capabilities that you have on the command line, you need to set it somehow within your Java program: import the PATH variable from the environment, set it within the code you're writing, or whatever mixture covers your needs.
Giving the absolute (full) path is the surest way, but you may not want to read such long command names in your source codes.
#harshithabt Per my experience, the issue was caused by the command azure could not be searched in the directories listed in PATH. There are two ways to solve the issue for running commands in Java, please see below.
Setting up the environment variable PATH for the current shell session or the configuration files ~/.profile(or ~/.bashrc).
If you command export PATH=<your-node-path>/bin:$PATH in a shell session, you only run the Java program with azure command in the current shell session, even run via the Java IDE which must be opened in the current shell session (it means you should open Eclipse via command <your-ide-path>/eclipse).
If you configure the files ~/.profile or ~/bashrc to add the node runtime as below, please make sure the configuration files have been reloaded via command source ~/.profile in a current session or restart sessions via logout & login or reboot.
A simple way is that adding the command links into the dirs listed in PATH, such as /bin. You just need to run the commands below.
sudo ln -s /bin/node /bin/node
sudo ln -s /bin/azure /bin/azure
Then you can run azure-cli command from Java successfully.
Environment: mac
Precondition: I already configured 'adb' full path to my bash_profile. and when I tried type 'adb' in my terminal, it is working.
But, I tried to exec 'adb' command from java, 'adb' is not working, instead I need to pass the full adb path to make it work.
I guess this is probably something to do with the bash_profile setting, anyone know the exact reason for this issue?
Runtime.getRuntime().exec() runs /bin/sh -c <command>. If this is or points to a bash shell on your system: A non-interactive bash does not read .bash_profile unless explicitly (--login) told to do so.
From the documentation:
When Bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior.
It's a little convoluted, but non-interactive, non-login bash instances don't read the profile files.
Your path settings does not get picked up by the subshell (which is actually /bin/sh which might not even be bash at all).
If you want, you can add the path to adb system wide by adding an appropriate entry to to /etc/paths.d.
I have a java web application project. I am using the exec-maven-plugin to execute a shell script which creates a small txt file in a directory when the project is built using mvn clean isntall. I have confirmed that the script is being executed when running mvn clean install by writing test text. However, the script is not creating the txt file.
When the script is run normally through the terminal, ie ./script.sh , the txt file is created correctly.
toTxt="hello"
printf $toTxt > testText.txt
echo 'This shows up, but testText is not created.'
Does anyone know the reason why this is happpening?
Try either echoing pwd command to see where it should create the file or add <workingDirectory>${project.build.outputDirectory}</workingDirectory>
to your configuration block in pom.xml
NOTE: You can specify something other than ${project.build.outputDirectory} to specifically point to the right place. And make sure you have write permissions to it.
Keep in mind that some commands are not really external programs, but shell built-ins. This means that they don't launch programs, and maven-exec-plugin will not be able to run them. However, you can run bash to get the result, just not pwd.
bash -c "echo $(pwd)"
should do the trick. Maven is launching bash which is then running the script echo $(pwd) which calls the bash builtin function pwd and passes the result back (due to the echo).
Yes, it's a lot of work to get around the lack of a pwd program, but that's because there really isn't a pwd program, it's part of the internal offerings of bash.
http://www.tldp.org/LDP/abs/html/internal.html lists the bash internals (builtin commands).
In the Process of installing spark 1.0.0 by double clicking the bin/spark-shell windows command script file. Then opened one command prompt file and then immediately closed it self only. Are there any commands required to run this. Could you please tell me step by step process.
First of all, you have to open a terminal. Theorically, you at least have the following on your machine :
cmd (for sure)
powershell (maybe not, if you're using Vista or less).
From there, you have two options :
if you added path_to_spark_folder\bin to your PATH variable (see there for more informations), you can run spark-shell as soon as the console is opened
if you didn't, you'll have to go to path_to_spark_folder\bin yourself, using the cd command.
You now can run spark-shell.
rI want to run jetty:run in debug mode with MAVEN_OPTS setted in environment variable. But it seams like hardcode MAVEN_OPTS. Is it possible to set MAVEN_OPTS in command line like mvn MAVEN_OPTS=...
Thank you.
Is it possible to set MAVEN_OPTS in command line like mvn MAVEN_OPTS=...
No, MAVEN_OPTS is an environment variable, you can't set it on the command line. But you there is an alternative. Instead of mvn, you can simply run mvnDebug (a little variation of the former script that set debug options):
$ mvnDebug jetty:run
Preparing to Execute Maven in Debug Mode
Listening for transport dt_socket at address: 8000
I find this alternative pretty handy, and easier.
Under Windows - I don't know. Under Linux/Bash - yes you can:
export MAVEN_OPTS="-Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
mvn jetty:run
Under Windows you should be able to do the following from the command prompt:
set MAVEN_OPTS=<options you want to add> %MAVEN_OPTS%
mvn jetty:run
Under Mac/Linux/Unix you can use export from the Terminal:
export MAVEN_OPTS=<options you want to add> $MAVEN_OPTS
mvn jetty:run
Not sure about how to do single use exports in Windows, but on Unix like operating systems you can just prepend the variable to your command (this works for any environment variable you want to add).
MAVEN_OPTS="option1 option2" mvn jetty:run
I encountered this problem, and my solution was to create a .bat file to set the maven opts, and then start jetty.
call set MAVEN_OPTS=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8484,server=y,suspend=n %MAVEN_OPTS%
call mvn jetty:run-war -DskipTests=true
My IDE of choice is Eclipse, so I use the run button with the tool box to call the .bat files. Here is a question on running a .bat file.