Cannot run program "adb" from IntelliJ plugin - java

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

Related

Running a Java/Selenium program on another computer

I have a small Java program that uses Selenium that I'd like to install on someone else's computer so they can use it too. It uses Selenium (for what it's worth).
I exported from Eclipse to a jar file. I then used launch4j to create a windows executable. I used Java version 1.7_079 to develop the program.
The other computer has JRE version 1.7_079 installed I made sure CLASSPATH is set.
If I run this executable on my system it works fine. If I try and run it on another system nothing happens at all, no errors, no nothing.
What am I doing wrong?
Would it be easier to NOT wrap it in an executable and just use a batch file to run it?
what's the best and easiest way to accomplish this?
Try to execute the .jar directly on the system where it doesn't work by using java.exe/javaw.exe and note the error, if any.
java.exe -jar helloworld.jar
If you get "'java.exe' is not recognized..." you need to add the folder where java/w.exe is to your path (eg: SET PATH=folder-with-java-exes;%PATH%
You can locate java/w.exe files with:
cd /d c:\
dir /S java*.exe
I finally have an answer to this. I traced it down to an issue with Chrome and Chrome driver. I was running Chrome v55.0.x. The users computer was running 57.0.. Once I upgraded my machine to 57. it failed like the users did. I updated Chrome driver and everything works as expected.
you can try this in your code put the path as C:/xxxxxxxx.exe
and put selenuim and the web driver In the C drive and create a jre or exe now .
next step is to ask your client to put selenuim and the web driver also in the C drive in there computers and int will work fine .

sourceanalyzer: command not found (mac)

I just installed a newer version of the Fortify package (4.30) but every time I try to use the command line to manually scan a project, I get an error that sourceanalyzer isn't an available option. I've tried reinstalling and I still cant get it to work. I can only scan in audit workbench. I never had this problem with earlier versions of Fortify.
Add this line to your ~/.bash_profile
alias sourceanalyzer="/Applications/HP_Fortify/HP_Fortify_SCA_and_Apps_4.xx/bin/sourceanalyzer"
Note: Where it says HP_Fortify_SCA_and_Apps_4.xx, put the version you are using here. Make sure your path is working and you shouldn't have to worry about it anymore. Don't forget to update this when you update your fortify application.
After this is done, just run the following command in your terminal:
source ~/.bash_profile
that will reload the bash_profile in your terminal.
Start /Applications/HP_Fortify/HP_Fortify_SCA_and_Apps_4.30/bin/sourceanalyzer
Open a new tab and run your fortify bash script or run sourceanalyzer command from here
It still will not run in my other terminal windows, but will only run in this one.
Is HP_Fortify/HP_Fortify_SCA_and_Apps_4.30/bin in your path system variable? For Windows, look at system properties, advanced, environment variables, then edit the PATH system variable and look for the entry for 4.30/bin.

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 ;)

Android.bat can't run java

I know this question has been beaten to death but I still cannot get the SDK Manager to run on my Windows 7 Home.
I downloaded the eclipse + adt bundle. The SDK Manager.exe is in the sdk folder where I try to run it from. I even tried copying it to the tools folder and tried running from there but no luck.
The error I get is:
Failed to execute tools\android.bat:
The system cannot find the file specified.
The file clearly exists. I tried running it as "Administrator" as well.
Next I tried running the android.bat file itself which says:
Windows cannot find 'E:\path\to\batfile'.
Make sure you typed the name correctly, and then try again.
I then ran it as "Administrator" which at least detects and tries to execute it. I added in a few pause statements to android.bat itself to prevent it from closing.
Here is what I see:
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal
or external command, operable program or batch file.
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java JDK installed on your system.
We recommend that you install the JDK version of JavaSE, available here:
http://www.oracle.com/technetwork/java/javase/downloads
If you already have Java installed, you can define the JAVA_HOME environment
variable in Control Panel / System / Avanced System Settings to point to the
JDK folder.
Not sure why it says that because when I run where java in cmd I get this:
C:\Users\(MyUser)>where java
C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
C:\Windows\System32\java.exe
And when I open cmd and manually run
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s'
it works fine.
I then tried setting the java_exe in android.bat to
set java_exe=C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
After commenting out the find_java I ran it again and this is what I get:
'"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar lib\archquery.jar' is not
recognized as an internal or external command,
operable program or batch file.
Invalid path
And once again, when I manually run it, I get:
C:\Users\MyUser>"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar E:\ADT\sdk\t
ools\lib\archquery.jar
x86_64
Am I missing something or should I finally give up trying to get it to work on my windows machine.
Your where java shows too many java.exe, the find_java.bat will try to look for javaw as well in the folder where java is.
set JAVA_HOME and make sure the echo %PATH% points to your main jdk installation.

Unable to execute .jar file

I'm having a problem with running .jar files. Here's what I've observed:
running executable .jar by doubleclicking doesn't do anything, not even start a process
running it from cmd by typing javaw myfile.jar doesn't do anything as well, I've redirected STDERR but it doesn't say anything
because of school requirements I'm developing in BlueJ, when I run my code directly from this IDE, it works and starts processes like java.exe or javaw.exe
when I try to compile my console program from cmd and then run it by java myclass, it works
I'm working on Windows 7 Professional with Java SE 7u51 JDK installed. I've already tried to uninstall anything that had "java" in its name and then install only JDK or only JRE. I've also tried to run jarfix or manually delete all .jar associations in registry. I've added my JRE path to other system variables. Nothing has worked for me.
Please do you have any idea what to try next? Thank you.
Resolved:
Thanks to the answers I've managed to resolve the problem with doubleclicking as well. I've just had to:
set the JAVA_HOME variable
restart the computer
run jarfix
Couple of quick solutions:
Use java -jar <jar-file-name>
Note: This will be useful if your jar is Runnable
Use java -cp <jar-file-name> main-class-name
Note: Specify the entry point with the class-name to start execution.

Categories