How to create a script to run the jar (while installing SBT)? - java

I am installing SBT on Mac. I am following the instructions mentioned (cryptically) on the website. I am now at the stage 'Installing sbt manually'. Under 'Unix', it reads:
Put sbt-launch.jar in ~/bin.
Create a script to run the jar, by creating ~/bin/sbt with these contents:
#!/bin/bash
SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"
java $SBT_OPTS -jar `dirname $0`/sbt-launch.jar "$#"
Make the script executable:
$ chmod u+x ~/bin/sbt
I have put sbt-launch.jar in the correct folder. But I do not understand what the rest means. How can you create the script: in the terminal? Is the code to make the script executable something that you have to execute once in the terminal?
(And after finishing the installation, how will you be able to open SBT?)

The easiest way for you to install sbt on macOS without much terminal interaction is homebrew. It's a popular package manager and it likely will be useful for you in the future. So just click the link and follow the instruction to install (it's just one command to paste to the terminal). The run
brew install sbt
That's it. Now to launch sbt you just run sbt command in a folder with your projects. Actually, these instructions are on the sbt web-site in the section 'Installing sbt on Mac'.
So if you are following 'Installing sbt manually' on purpose, the "Create a script" part means just to create a "text file" in any editor you use, paste those lines in it, and save to the proper location. Then run chmod command in the terminal. That's it.
About adding something to PATH check this article.

Related

My java program runs in netbeans, but will not run in command or through the jar file. What am I doing wrong?

So, I am trying to run a program from jar files. It uses javaswing and has a gui.
The program runs fine in netbeans and in eclipse.
When I try to run it from the exported jar file it says this:
Unable To Install Java
There are errors in the following switches:
"C:\Users\CNC Department\Desktop\ValveConversion.jar";.
Check that the commands are valid and try again.[java installation not complete
Now, I also tried doing it from the command prompt. Here is what came up:
[cmd prompt attempt][1] [1]: https://i.stack.imgur.com/7reZ3.png
So, I reinstalled the java JDK, java SDK, netbeans and eclipse. The issue is still occurring in both command prompt and from running the jar file directly.
What am I doing incorrectly here? What do you recommend that I do to get this to run from a .jar file?
You need to set the java path
Open a cmd with elevated privileges and run this command to set the JAVA_HOME environment variable using setx command:
setx JAVA_HOME -m "C:\Program Files\Java\jdk-11.0.2"
Then restart the cmd and run java -version to check if it's all ok.
For reference setx command documentation
Or simply use the following snippet if you prefer to use java without setting the PATH variable:
"C:\Program Files\Java\jdk-11.0.2\bin\java" -jar "C:\Users\CNC Department\Desktop\ValveConversion.jar"

Can't set up Maven on Mac OSX

I am new to Mac OSX and I'm running Yosemite. I am trying to set up Maven using this official guide in order to set up a Google Cloud Messaging Backend. Here's what I did:
1) Downloaded Maven zip (version: apache-maven-3.3.9) and Unzipped it
2) As the guide says, I need to add the bin directory to my PATH variable. So I did the following in my terminal
export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
The terminal didn't return any response. However when I checked to see if Maven got installed using:
mvn -version
I get a message saying:
-bash: mvn: command not found
What am I doing wrong? Did I follow the steps properly to set up Maven?
EDIT:
MVN Bin Directory path is:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
I tried all the manual steps here and still couldn't get it to work. Then I realized I can easily install it using Homebrew, much more convenient:
brew install maven
that's all you need to install maven for mac!
The $PATH is what point where your programs are, because of that you change it in order to find mvn. Actually you are pointing $PATH to $M2_HOME/bin.
You need to update $M2_HOME to one directory level before mvn bin and before update $PATH.
If this is your mvn home:
/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9
you should use this env vars:
export M2_HOME="/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9"
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_60"
export PATH="$JAVA_HOME/bin:$M2_HOME/bin:$PATH"
You can also edit your ~/.profile in order to include these lines, so you don't need to type these exports whenever you open your terminal.
Do
export M2_HOME=/Users/Earthling/Documents/Projects/MobiProject/apache-maven-3.3.9

Not able to build Android calabash environment on windows

For building the environment I've installed/use OS Windows 8.1, eclipse, Android SDK, JDK, ruby installer, DevKit installed. Also I've set path for ANDROID_HOME, JAVA_HOME. I've tried maximum ways to resign JAR but not getting that jar so I'm stuck at the point and unable to move forward. did google for my problem. Now I got confused what will be step by step execution to make my environment to run? Or shall I need to build this structure on Linux to make it easier run?
First open 'CMD' or 'CMD with Ruby'
Run the following command
cucumber --version
if cmd shows cucumber version, proceed to next step
calabash-android version
if cmd show calabash-android version, you're ready to run calabash-android testcase.
Then create a folder, cd to that folder and run these commands.
$ calabash-android gen #this will create folder structure
$ calabash-android resign apk_path/<apkfile.apk>
$ calabash-android build apk_path/<apkfile.apk>
$ calabash-android console apk_path/<apkfile.apk>
You will see interactive ruby editor, now type the following command
$ start_test_server_in_background # app will install in connected device.
Then
$ query("*")
Now you can see all the elements in your android application!!
If you face any error/issue in any steps, your setup may be incomplete.

I am getting the following error when I run mvn on OS X Mavericks: Cannot run program "/bin/sh": error=2, No such file or directory

I am running OS X Mavericks on a MacBook Pro.
I have maven 3.0.5 installed.
When I run mvn, I am getting the following error message.
Error while executing process. Cannot run program "/bin/sh": error-2, No such file or directory
And before you ask:
PATH="/usr/local/apache-maven-3.0.5/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin:/usr/local/bin:/bin:/usr/bin"
M2_HOME="/usr/local/apache-maven-3.0.5"
M2="/usr/local/apache-maven-3.0.5/bin"
MAVEN_OPTS="-Xms256m -Xmx768m -XX:MaxPermSize=512m"
I am also seeing the following near the beginning of the mvn output:
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Failed to use environment variables for interpolation: Cannot run program "env": error=0, spawn failed #
I had the same problem: exec() failed with ANY executable. Finally remembered that I was using a private jre. That jre was a copy of the original one, just with bin/java set as executable.
I made lib/jspawnhelper executable and it worked!
If you are using eclipse , this is due to the java version. point java to your OS java instead of eclipse java. this will be solved
It seems your system is missing the "sh" shell to start interpreting the script.
I just looked up installed shells on Mac OSX and got this result:
/bin/zsh
/bin/ksh
/bin/tcsh
/bin/bash
/bin/sh
So when "/bin/sh" is missing, try "/bin/bash" for example.
Better:
Check if "/bin/sh" exist
If exist check if the user which runs the command can execute the shell
Because it can be possible that the shell binary exist but isn't executable for you. Then you have to make it executable for the user trying mvn.
Hope that helps ;)

Cannot run program "adb" from IntelliJ plugin

My problem is that I want to run shell command from Java code (my IntelliJ plugin):
Runtime.getRuntime().exec("adb devices")
But then I receive IOException:
Cannot run program "adb": error=2, No such file or directory.
What is odd is that when I run it on debug mode it works, it's broken only when I deploy my plugin to real IntelliJ. The command also works from any terminal.
The only thing which works now it typing the command with full path:
/Users/adamstyrc/utils/adb
But it's not a solution. How to fix it ? My guess would be to manually load bash PATH variable add adb exec file to project but it's not elegant solution. Thanks in advance!
You need to be sure that the correct path settings are passed to IntelliJ.
If you for example modified the path settings, or if you ran intellij from a different terminal or user, then they might not be correct.
To be sure, close down IntelliJ, start a new terminal - then verify the path settings - and start IntelliJ manually from that terminal.
If you are running a 64 bit machine, try installing 32-bit libraries using
apt-get install ia32-libs

Categories