Ejemplo n.º 1
0
Archivo: ex3.c Proyecto: WareX97/AJVM
int main(int argc, char** argv) {

	/* Initialize VM */
	avm_init();

	/* Open Native.class */
	if(avm_open("Native.class") == J_ERR)
		{ perror("Native.class"); abort(); }

	/* Register a native function from "unistd.h" : Object Native.getenv(Object Env); */
	java_native_add("Native", "getenv", "L", T_REFERENCE, getenv);

	/* Initialize context & resolve assemblies */
	avm_begin();

	/* Native.PrintHello(); */
	const char* path = (const char*) avm_call("Native", "GetPath", 0).ptr;

	/* Destroy context & all resources */
	avm_end();

}
Ejemplo n.º 2
0
int main(int argc, char** argv) {
    
    
    static struct option long_options[] = {
        { "verbose", no_argument, NULL, 'v'},
        { "help", no_argument, NULL, 'h'},
        { "version", no_argument, NULL, 'q'},
        { NULL, 0, NULL, 0 }
    };
    
    
    int verbose = 0;
    
    
    int c, idx;
    while((c = getopt_long(argc, argv, "qv", long_options, &idx)) != -1) {
        switch(c) {
            case 'v':
                verbose = 1;
                break;
            case 'q':
                show_version(argc, argv);
                break;
            case 'h':
            case '?':
                show_usage(argc, argv);
                break;
            default:
                abort();
        }
    }
    
    
	
	avm_init();
	avm_config_path_add("/usr/lib/avm");
	avm_config_path_add("/usr/local/lib/avm");
	avm_config_path_add("/usr/share/java");
	
	signal(SIGINT, sighandler);
	signal(SIGILL, sighandler);
	signal(SIGFPE, sighandler);
	signal(SIGSEGV, sighandler);
	
	
	ZETA_LIBRARY_LOAD();
 
	 
	if(avm_open_library("rt.jar") == J_ERR) {
		perror("rt.jar");
		return 0;
	}
	
	if(avm_open_library("zeta.jar") == J_ERR) {
		perror("zeta.jar");
		return 0;
	}
    
	
	avm_begin();
	__Z(Activity_Load) ("zCore");
    avm_end();
	
	return 0;
}