1 /* Copyright (C) 1999, 2000, 2001 Free Software Foundation
3 This file is part of libgcj.
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
9 /* Author: Kresten Krab Thorup <krab@gnu.org> */
15 #include <java-props.h>
21 #include <java/lang/System.h>
22 #include <java/util/Properties.h>
27 printf ("Usage: gij [OPTION] ... CLASS [ARGS] ...\n");
28 printf (" to interpret Java bytecodes, or\n");
29 printf (" gij -jar [OPTION] ... JARFILE [ARGS] ...\n");
30 printf (" to execute a jar file\n\n");
31 printf (" -DVAR=VAL define property VAR with value VAL\n");
32 printf (" --help print this help, then exit\n");
33 printf (" --ms=NUMBER set initial heap size\n");
34 printf (" --mx=NUMBER set maximum heap size\n");
35 printf (" --version print version number, then exit\n");
36 printf ("\nSee http://gcc.gnu.org/java/ for information on reporting bugs\n");
43 printf ("gij (GNU libgcj) version %s\n\n", VERSION
);
44 printf ("Copyright (C) 2001 Free Software Foundation.\n");
45 printf ("This is free software; see the source for copying conditions. There is NO\n");
46 printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
51 main (int argc
, const char **argv
)
53 /* We rearrange ARGV so that all the -D options appear near the
55 int last_D_option
= 0;
56 bool jar_mode
= false;
59 for (i
= 1; i
< argc
; ++i
)
61 const char *arg
= argv
[i
];
63 /* A non-option stops processing. */
66 /* A "--" stops processing. */
67 if (! strcmp (arg
, "--"))
73 if (! strncmp (arg
, "-D", 2))
75 argv
[last_D_option
++] = arg
+ 2;
79 if (! strcmp (arg
, "-jar"))
85 /* Allow both single or double hyphen for all remaining
90 if (! strcmp (arg
, "-help"))
92 else if (! strcmp (arg
, "-version"))
94 /* FIXME: use getopt and avoid the ugliness here.
95 We at least need to handle the argument in a better way. */
96 else if (! strncmp (arg
, "-ms=", 4))
97 _Jv_SetInitialHeapSize (arg
+ 4);
98 else if (! strcmp (arg
, "-ms"))
103 fprintf (stderr
, "gij: option requires an argument -- `%s'\n",
105 fprintf (stderr
, "Try `gij --help' for more information.\n");
108 _Jv_SetInitialHeapSize (argv
[++i
]);
110 else if (! strncmp (arg
, "-mx=", 4))
111 _Jv_SetMaximumHeapSize (arg
+ 4);
112 else if (! strcmp (arg
, "-mx"))
116 _Jv_SetMaximumHeapSize (argv
[++i
]);
120 fprintf (stderr
, "gij: unrecognized option -- `%s'\n", argv
[i
]);
121 fprintf (stderr
, "Try `gij --help' for more information.\n");
126 argv
[last_D_option
] = NULL
;
127 _Jv_Compiler_Properties
= argv
;
131 fprintf (stderr
, "Usage: gij [OPTION] ... CLASS [ARGS] ...\n");
132 fprintf (stderr
, " to interpret Java bytecodes, or\n");
133 fprintf (stderr
, " gij -jar [OPTION] ... JARFILE [ARGS] ...\n");
134 fprintf (stderr
, " to execute a jar file\n");
135 fprintf (stderr
, "Try `gij --help' for more information.\n");
139 _Jv_RunMain (NULL
, argv
[i
], argc
- i
, argv
+ i
, jar_mode
);