gospider not run in intellij
Answered
gospider could not run in intellij with command ProcessBuilder but jar file of this code run on terminal
please send me email :
saeedalikn3@gmail.com
Please sign in to leave a comment.
Hello,
Can you provide more info? Is it executed in a plugin code or a normal Java program? What operation system you are using?
Hello ,
os :ubuntu 22.04
and code is like this :
ProcessBuilder processBuilder = new ProcessBuilder("gospider", "-s", "ip") in java
or
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
but it run if run jar file in terminal but not in intellij, did you run gospider in intellij and get result?
Thank You
Please try to launch the PhpStorm from a terminal by this guide: https://intellij-support.jetbrains.com/hc/en-us/articles/360011901879-How-to-start-IDE-from-the-command-line
Or try set envs for desktop apps here:
https://wiki.archlinux.org/title/environment_variables#Graphical_environment
Please talk back if this still not works.
i work with intellij for java,PhpStorm is for php
i run intellij from terminal like this cd ‘~/Software/IntelliJ IDEA 2023.3/bin’ ./idea.sh but it did not work
but i run go version and gospider --version inside intellij like that command and it work
* Run whereis gospider in your Terminal and share the output.
* Run System.out.println(System.getenv("PATH")); in a Java file in IntelliJ and share the output for it.
* Run echo $PATH in Terminal and share the output.
It seems the PATH is somewhat different in Terminal and in IntelliJ.
whereis gospider:
gospider: /home/sam-hx/go/bin/gospider /usr/local/go/bin/gospider
System.out.println(System.getenv("PATH")):
/usr/local/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/sam-hx/go/bin:/home/sam-hx/go/bin:/usr/local/go/bin
echo $PATH in Terminal:
/usr/local/bin:/usr/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/sam-hx/go/bin:/home/sam-hx/go/bin:/usr/local/go/bin
If you open the Terminal and run your Java file code directly (without using jar), can it run fine? Is it stuck when running and doesn't print out anything either?
I have tried the similar code using ProcessBuilder in the Terminal directly (not using jar), and it shows the same results, so this seems not an IntelliJ issue. See the attached video here: https://uploads.jetbrains.com/files/2024_01_29_MHXyHghq51uVUTAd8TEseT_JBS/Screencast_20240129_140751-1.webm?secret=EJbE4tjsWkKMikTJ335Poec6NwKCa2TB
If you open the Terminal and run your Java file code directly (without using jar), can it run fine
No!!! do you know why ?
my source code is same with your code but it wait before while →while ((readLine = processOutputReader.readLine()) != null)
exactly here .. processOutputReader.readLine()
From my testing, adding `process.getOutputStream().close();` before a while loop helps.
Also, if I use the `ProcessBuilder` to run `gospider --help`, it doesn't have this issue.