Java Utilities - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Random Posts


java vs. javaw

When a Java application is launched with java command, JVM uses the command window as a console.

If you don't want this console window, you can use javaw command to launch the application. The difference between java and javaw is javaw does not create any console whereas java does.

Here is what I did to test the javaw tool.

1. Write and compile Test.java

2. Open a command window to run Test.class using java Test.

3. Look at the output shown in the window, which is not showing any more. Because the window is being used as console for java tool.

4. Now, run the program using javaw Test.

5. Look at the output again, the command prompt is asking to provide any new commands.

6. To understand what happens to this program? Check the process list for both java and javaw. In both case they are listed in process list.

Hope, you understand that javaw is used to launch an application where console window is not needed. So javaw is good tool for the applications like GUI applications and server applications.

In both case file redirexction is supported. Let us test it.

public class Test { public static void main(String args[]) { System.out.println("Hello"); } }


#javac Test.java #java Test > my1.log #javaw Test > my2.log


public class Test { public static void main(String args[]) { Scanner c = new Scanner(System.in); System.out.println("Hello" + c.nextInt()); } }


#javac Test.java

Create a file containing a integer number


#vi myInput.file #java Test < myInput.file #javaw Test < myInput.file

Now you can understand that I/O can be associated with both.

As javaw.exe does not need command line window to appear. If error occurs at the time of execution, the error is shown in a dialog box.

java.exe can be used when input and output texts are read from or shown on console.

As IDEs (like Netbeans, Eclipse etc.) are using their internal console instead of system console they are using javaw instead of java.

javap

The javap command is used to disassemble one or more class files and prints the output to stdout. You can use different options according to your requirements. If you receive a class file, you can check name of the package, methods, variables etc. as shown below.


package com.abcbank.account; public abstract class Account { private int _accountNo; private String _customerName; private String _customerAddress; private String _branchName; private String _branchAddress; private float _amount; private float _rateOfInterest; public int get_accountNo() { return _accountNo; } public void set_accountNo(int _accountNo) { this._accountNo = _accountNo; } public String get_customerName() { return _customerName; } public void set_customerName(String _customerName) { this._customerName = _customerName; } public String get_customerAddress() { return _customerAddress; } public void set_customerAddress(String _customerAddress) { this._customerAddress = _customerAddress; } public String get_branchName() { return _branchName; } public void set_branchName(String _branchName) { this._branchName = _branchName; } public String get_branchAddress() { return _branchAddress; } public void set_branchAddress(String _branchAddress) { this._branchAddress = _branchAddress; } public float get_amount() { return _amount; } public void set_amount(float _amount) { this._amount = _amount; } public float get_rateOfInterest() { return _rateOfInterest; } public void set_rateOfInterest(float _rateOfInterest) { this._rateOfInterest = _rateOfInterest; } }

The output of javap command without any option.

The output of javap command with -c option.

jconsole

jconsole is monitoring and management tool for local and remote processes.

Select a process from the list and connect. You will see the following screen.




Happy Exploring!

No comments:

Post a Comment