.. | .. |
---|
595 | 595 | |
---|
596 | 596 | public static void main(String argv[]) |
---|
597 | 597 | { |
---|
598 | | - if (false) // argv.length == 0) |
---|
| 598 | + String osArch = System.getProperty("os.arch"); |
---|
| 599 | + System.out.println("os.arch = " + osArch); |
---|
| 600 | + |
---|
| 601 | + if (argv.length == 0) |
---|
599 | 602 | { |
---|
600 | | - String javaPath = System.getProperty("java.home") + "/bin/java"; |
---|
| 603 | + String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; |
---|
| 604 | + System.out.println("javaPath = " + javaPath); |
---|
601 | 605 | java.net.URL u = new GrafreeD().getClass().getResource("default.png"); |
---|
602 | 606 | |
---|
603 | | - System.out.println(u); |
---|
| 607 | + System.out.println("URL = " + u); |
---|
604 | 608 | |
---|
605 | 609 | String jarfile = u.toString().split("file:")[1].split("default.png")[0]; |
---|
606 | 610 | |
---|
| 611 | + System.out.println("jarfile0 = " + jarfile); |
---|
| 612 | + |
---|
607 | 613 | String jarpath = u.toString().split("file:")[1].split("GrafreeD.jar")[0]; |
---|
608 | 614 | |
---|
609 | | - System.out.println(jarfile); |
---|
610 | | - System.out.println(jarpath); |
---|
| 615 | + System.out.println("jarpath0 = " + jarpath); |
---|
611 | 616 | |
---|
612 | 617 | jarfile = jarfile.substring(0, jarfile.length() - 2); |
---|
613 | 618 | |
---|
614 | | - // -Djava.library.path=/Users/nbriere/Projects/shared/lib |
---|
| 619 | + System.out.println("jarfile = " + jarfile); |
---|
| 620 | + |
---|
| 621 | + String command = javaPath + " -Xmx1024m -Djava.library.path=" + jarpath; |
---|
615 | 622 | |
---|
616 | | - String command = "" + javaPath + " -Xmx1024m -Djava.library.path=" + jarpath + "lib -jar " + jarfile + " dummyarg"; |
---|
| 623 | + // -Djava.library.path=/Users/nbriere/Projects/shared/lib |
---|
| 624 | + if (jarfile.charAt(2) == ':') |
---|
| 625 | + { |
---|
| 626 | + command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath; |
---|
| 627 | + // On Windows systems, the path is /C:/ |
---|
| 628 | + jarfile = jarfile.substring(1, jarfile.length()); |
---|
| 629 | + System.out.println("jarfile = " + jarfile); |
---|
| 630 | + jarpath = jarpath.substring(1, jarpath.length()); |
---|
| 631 | + System.out.println("jarpath = " + jarpath); |
---|
| 632 | + command += "native" + File.separator; |
---|
| 633 | + if (osArch.equals("amd64")) |
---|
| 634 | + command += "windows_amd64"; |
---|
| 635 | + else |
---|
| 636 | + command += "windows_i586"; |
---|
| 637 | + } |
---|
| 638 | + else |
---|
| 639 | + command += "native" + File.separator + "macosx"; |
---|
| 640 | + |
---|
| 641 | + command += " -jar " + jarfile + " dummyarg"; |
---|
617 | 642 | |
---|
618 | 643 | try |
---|
619 | 644 | { |
---|
620 | | - System.out.println(command); |
---|
| 645 | + System.out.println("command = " + command); |
---|
621 | 646 | Runtime.getRuntime().exec(command); |
---|
622 | 647 | |
---|
623 | 648 | return; |
---|
.. | .. |
---|
626 | 651 | { |
---|
627 | 652 | e.printStackTrace(); |
---|
628 | 653 | } |
---|
| 654 | + |
---|
| 655 | + /* |
---|
| 656 | + if (argv.length == 0) |
---|
| 657 | + { |
---|
| 658 | + String javaPath = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; |
---|
| 659 | + System.out.println("javaPath = " + javaPath); |
---|
| 660 | + java.net.URL u = new Grafeme().getClass().getResource("grafeme.jpg"); |
---|
| 661 | + System.out.println("URL = " + u); |
---|
| 662 | + |
---|
| 663 | + String jarfile = u.toString().split("file:")[1].split("grafeme/grafeme.jpg")[0]; |
---|
| 664 | + System.out.println("jarfile0 = " + jarfile); |
---|
| 665 | + |
---|
| 666 | + jarfile = jarfile.substring(0, jarfile.length() - 2); // Remove "!/" after .jar |
---|
| 667 | + System.out.println("jarfile = " + jarfile); |
---|
| 668 | + |
---|
| 669 | + if (jarfile.charAt(2) == ':') |
---|
| 670 | + { |
---|
| 671 | + // On Windows systems, the path is /C:/ |
---|
| 672 | + jarfile = jarfile.substring(1, jarfile.length()); |
---|
| 673 | + System.out.println("jarfile = " + jarfile); |
---|
| 674 | + } |
---|
| 675 | + |
---|
| 676 | + String command = "\"" + javaPath + "\" -Xmx1024m -jar " + jarfile + " dummyarg"; |
---|
| 677 | + |
---|
| 678 | + try |
---|
| 679 | + { |
---|
| 680 | + System.out.println(command); |
---|
| 681 | + Runtime.getRuntime().exec(command); |
---|
| 682 | + |
---|
| 683 | + return; |
---|
| 684 | + } |
---|
| 685 | + catch (Exception e) |
---|
| 686 | + { |
---|
| 687 | + e.printStackTrace(); |
---|
| 688 | + } |
---|
| 689 | + } |
---|
| 690 | + |
---|
| 691 | + */ |
---|
629 | 692 | } |
---|
630 | 693 | |
---|
631 | 694 | // InitDictionary(); |
---|