mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-17 09:10:08 +02:00
openjdk: provide hjava launcher utility.
This commit is contained in:
24
dev-lang/openjdk/sources/hjava.cpp
Normal file
24
dev-lang/openjdk/sources/hjava.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
system("alert --stop \"Java: Please specify a Jarfile.\" >/dev/null");
|
||||
return 1;
|
||||
}
|
||||
|
||||
char command[PATH_MAX];
|
||||
snprintf(command, sizeof(command), "%s -jar \"%s\"", JAVA_BINARY, argv[1]);
|
||||
|
||||
FILE* fd = popen(command, "r");
|
||||
if (fd != NULL) {
|
||||
char buffer[512];
|
||||
fgets(buffer, 512, fd);
|
||||
return pclose(fd);
|
||||
} else
|
||||
system("alert --stop \"Java: popen failed!\" >/dev/null");
|
||||
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user