'Cant run curl command from java code in Linux OS

i have this curl

String curlStr = "curl 'http://somesite/env=dev'";

when i run this command in cmd it works but it doesnt work from java code This is what i tried

Runtime.getRuntime().exec(curlStr);


Solution 1:[1]

I can't remember exactly the reason but this works :

Runtime.getRuntime().exec("/bin/sh -c " + curlStr);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Seb34