From: Slava P. <sp...@gj...> - 2000-11-23 01:22:19
|
Reinout van Schouwen wrote: > > Hi all, > > I have a (possibly stupid) question: > > Since I can compile java apps in the console with JCompiler, can I run > them from the console too without spawning a new java process? > > Would I have to make my main class Runnable? I imagine this would be possible, but might cause strange problems with programs that use static variables and the like. Eg, consider this program: public class MyApp { static Vector data = new Vector(); static initData() { data.addElement("1"); data.addElement("2"); ... } public static void main() { initData(); } } This program might rely in the 'data' vector containing only the elements added in initData(), however, if main() is called twice, the data vector) will only be initialized the first time (when the class is loaded) and as a result it will contain two copies of everything. Slava Slava |