#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<unistd.h>

#define MAX_PATH_SIZE 250
#define LOG_HOLDER_SIZE 500

void logVar(char * message, char * var);

int main(){
	char currentWorkingDirectory[MAX_PATH_SIZE];
	if(getcwd(currentWorkingDirectory,sizeof(currentWorkingDirectory)) != NULL){
	} else {
		printf("Failed to get current working directory!\n");
		fflush(stdout);
		return 1;
	}
	//printf("CWD: %s\n",currentWorkingDirectory);
	//fflush(stdout);
	//get java location
	char javaPath[MAX_PATH_SIZE + 50];
	strcpy(javaPath,currentWorkingDirectory);
	strcat(javaPath,"\\jdk\\bin\\java.exe\0");
	//get jar location
	char jarPath[MAX_PATH_SIZE + 50];
	strcpy(jarPath,currentWorkingDirectory);
	strcat(jarPath,"\\engine.jar");
	logVar("javaPath: ",javaPath);
	logVar("jarPath:  ",jarPath);
	printf("%s\n",jarPath);
	fflush(stdout);
	execlp(javaPath,"java","-jar",jarPath, (char *)NULL);
	return 0;
}


char logHolder[LOG_HOLDER_SIZE];
void logVar(char * message, char * var){
	strcpy(logHolder,message);
	strcat(logHolder,var);
	printf("%s\n",logHolder);
	fflush(stdout);
}
