Posts

Showing posts from January, 2011

Showing "Generate Java Bean Skeleton Dialog" Setting in Eclipse

Image
"Generating Java Bean Skeleton" facility is essential of Top Down web service development at Eclipse and Eclipse based IDEs. Right click on wsdl, select Web Services > Generate Java bean skeleton; on the incoming panel, there is a checkbox exists says " Do not show me this dialog box again. ". If this is selected once, then it applies the default settings to next web service code generation procedures. In order to get rid of default settings and show web service generation wizard again, go to Window > Preferences > Web Services > Popup Dialog Selection and uncheck " Hide Generate Java Bean Skeleton Dialog " box.

Time Limited Loop in Java

Image
Executing a loop in a given time duration is a challanging question that I' ve found at StackOverFlow . There are many solutions offered by SOF posters. The asker's wish is as follows; but implementation is just a little bit more complex than what he thinks. int x = 0; for( 2 minutes ) { System.out.println(x++); } My solution is implementing a stopper thread in an inner class that will sleep for intended duration, then invokes setStop(true) method of the class to break the condition of loop. To succeed in this, the condition of the time limited loop must depend on " isStop() " method. // The loop will stop in 2 sec. StopperThread stopperThread = new StopperThread(2000); //if isStop returns true, then the next check of condition //will break the loop. while (index < limit && !isStop()) { System.out.println("#Did sth: " + index); index += increment; } Stopper thread is implemented in order to sleep in a given time as constructor parame

Process Builder Demo

Image
In order to create operating system processes (even another java application), running a command, and defining an environment variable; a simple approach is succeeded by using " java.lang.ProcessBuilder " class in Java . Process process = Runtime.getRuntime().exec("cmd /c java -cp bin B"); BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; while( (line = inputStream.readLine()) != null) { // inputStream is enabling this thread(main method) // to read "System.out" prints of started process (B.main method) System.out.println("#read from inputStream: " + line); } The above example illustrates how to start a java application from another one. /c option has vital importance since the rest of the parameters that command line is fed to run them properly. java command must be in environment variables to run B (which consists the " main(String[] args) " method) and -cp is sta