Display java console windows

Display java console windows

Whether a virtual machine has a console is dependent upon the underlying platform and also upon the manner in which the virtual machine is invoked. If the virtual machine is started from an interactive command line without redirecting the standard input and output streams then its console will exist and will typically be connected to the keyboard and display from which the virtual machine was launched. If the virtual machine is started automatically, for example by a background job scheduler, then it will typically not have a console.

If this virtual machine has a console then it is represented by a unique instance of this class which can be obtained by invoking the System.console() method. If no console device is available then an invocation of that method will return null.

Read and write operations are synchronized to guarantee the atomic completion of critical operations; therefore invoking methods readLine() , readPassword() , format() , printf() as well as the read, format and write operations on the objects returned by reader() and writer() may block in multithreaded scenarios.

Invoking close() on the objects returned by the reader() and the writer() will not close the underlying stream of those objects.

The console-read methods return null when the end of the console input stream is reached, for example by typing control-D on Unix or control-Z on Windows. Subsequent read operations will succeed if additional characters are later entered on the console’s input device.

Unless otherwise specified, passing a null argument to any method in this class will cause a NullPointerException to be thrown.

Security note: If an application needs to read a password or other secure data, it should use readPassword() or readPassword(String, Object. ) and manually zero the returned character array after processing to minimize the lifetime of sensitive data in memory.

Method Summary

Methods
Modifier and Type Method and Description
void flush()
char[] readPassword(String fmt, Object. args)

Methods inherited from class java.lang.Object

Method Detail

writer

reader

This method is intended to be used by sophisticated applications, for example, a Scanner object which utilizes the rich parsing/scanning functionality provided by the Scanner:

For simple applications requiring only line-oriented reading, use readLine(java.lang.String, java.lang.Object. ) .

The bulk read operations read(char[]) , read(char[], int, int) and read(java.nio.CharBuffer) on the returned object will not read in characters beyond the line bound for each invocation, even if the destination buffer has space for more characters. A line bound is considered to be any one of a line feed ('\n'), a carriage return ('\r'), a carriage return followed immediately by a linefeed, or an end of stream.

format

printf

An invocation of this method of the form con.printf(format, args) behaves in exactly the same way as the invocation of .

readLine

readLine

readPassword

readPassword

flush

  • Summary:
  • Nested |
  • Field |
  • Constr |
  • Method
  • Detail:
  • Field |
  • Constr |
  • Method

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Java Console

These documentation pages are no longer current. They remain available for archival purposes. Please visit https://docs.oracle.com/javase for the most up-to-date documentation.

The following topics are covered:

What is Java Console?

Java Console is a simple debugging aid that redirects any System.out and System.err to the console window. It is available for applets running with Java Plug-in and applications running with Java Web Start.

Debugging Options

Java Console provides various options as shown below to make applet and application debugging easier.

An action/option is selected by typing its letter/number while the Java Console window has focus.

This removes (destroys) all ClassLoader objects in the cache.

Modified jar files will be downloaded from the server when a page with an applet is refreshed or revisited if you first do this: type «x» in the Java Console to clear the Classloader cache.

Key Description
c: Clears the Java Console window.
f: Triggers finalization on the objects in the finalization queue and then displays memory information. Memory refers to the current heap size used by the JRE. Free is the available memory that is free in the heap. The percent (xx%) is the free memory as a percent of the total heap size.
g: Triggers garbage collection and displays memory information as described above.
h: Displays help message, which is being described here.
l: Displays a list of the cached ClassLoader objects in the Java Plug-in. Classes are cached to avoid having to load them again when returning to previously-visited pages. When a page is visited the first time, a ClassLoader object will be created and all of the classes that are downloaded will be cached in that object. These objects are created and cached according to their codebase . To identify a ClassLoader object, the «classloader list» displays the codebase for that object. Additional information displayed with a ClassLoader object includes zombie , cache and info . zombie = true indicates that a ClassLoader object is not being used (i.e., the applet is not currently loaded on the page). cache = true indicates that the applet should be cached, while false indicates that the applet will be destroyed when the page is left. info is a value used for debugging.
m: Displays heap memory usage as described above.
o: Triggers logging, which directs output from the Java Plug-in Console to a log file.
p: Reloads the proxy configuration.
q: Causes the Java Console to disapper from the main screen.
r: Reloads the policy configuration.
s: Prints out the system properties. This is mostly for debugging.
t: Prints out all the existing thread groups. The first group shown is Group main . ac stands for active count; it is the total number of active threads in a thread group and its child thread groups. agc stands for active group count; it is the number of active child thread groups of a thread group. pri stands for priority; it is the priority of a thread group. Following Group main , other thread groups will be shown as Group name > , where name is the URL associated with an applet. Individual listings of threads will show the thread name, the thread priority, alive if the thread is alive or destroyed if the thread is in the process of being destroyed, and daemon if the thread is a daemon thread.
x:
0-5: This sets the trace-level options as described in Tracing and Logging.

Task-Bar Integration

When Java Plug-in is running an icon is displayed in the taskbar for Windows or on the desktop for Solaris. When right-clicked, a menu option displays, allowing the user to Open/Hide the Java Console. Thus the user can open and hide the Java Console any number of times within the same browser session.

Startup Behavior

Java Console may be shown, hidden, or not started at startup time, as configured through the Java Control Panel in the Advanced tab.

Using the Java Plug-in Control Panel to Set Plug-in Behavior/Options

This section covers the following topics:

Overview

The Java TM Plug-in Control Panel enables you to change the default settings used by the Java Plug-in at startup. All applets running in an active instance of Java Plug-in use these settings.

Starting the Java Plug-in Control Panel

On Windows: From the Windows Control Panel, double-click the Java coffee-cup icon labeled Java Plug-in to launch the Java Plug-in Control Panel.

On Solaris and Linux: You can run the Control Panel by launching the ControlPanel executable file. In the Java 2 SDK, this file is located at:

It is also located at:

For example, if your Java 2 SDK is installed at /usr/j2se, launch the Control Panel with this command:

Saving Options

When you have completed your changes to the Control Panel options, click Apply to save the changes. Click Reset to cancel your changes and reload the last values that were entered and applied. Note that this is not the same as the set of default values that were originally set for Java Plug-in when it was installed.

Control Panel Help

Help for Java Plug-in is available from any panel in the Control Panel. Help comes up in its own window in response to pushing the Help button and looks like this:

Setting Control Panel Options

There are eight sub-panels (tabs) in the Java Control Panel. From six of them you can set various options. The panels are labeled:

Each is described separately below.

The settings shown for check boxes and radial buttons in each panel below, with the exception of the Browser panel, are the default (installation) settings. The check boxes for the Browser panel are determined according to user selection during installation.

Basic Panel

The Basic panel looks like this:

Use the Basic panel to set the following options:

Show Java Console

Displays the Java Console while running applets. The console displays messages printed by System.out and System.err objects. It is useful for debugging problems.

Hide console

The console is running but hidden. This is the default setting (checked).

Do not start console

Show Java in System Tray (Windows only)

The Show Java in System Tray option indicates to the user that a Java VM is running, and it provides information about the Java release and control over the Java Console. When enabled and Java Plug-in is started, the coffee-cup logo displays in the system tray. When Java Plug-in is shutdown, the icon is removed from the system tray. This option is enabled by default (checked).

If Show Java in System Tray is checked, the icon will show up in the system tray even if Do not start console is selected.

If the mouse is pointed at the icon, the text «Java» is displayed.

When the system tray icon is left-double-clicked, the Java Console window will be brought up. When the system tray icon is right-clicked, a popup menu will be shown with following menu items:

Open/Close Console menu item will display Open Console if the Java Console is hidden. If the Java Console is showing, Close Console will display as the first menu item. Clicking on the first menu item opens/closes the Java Console window.

About Java will bring up the About — Java box for Java Plug-in.

Disable removes the icon from the system tray until the user re-enables it and Java Plug-in is restarted (browser is closed, then reopened on a page with an applet).

To re-enable the icon, start the Java Plug-in Control Panel, check Show Java in System Tray, and press Apply.

Exit removes the icon from the system tray until Java Plug-in is restarted.

If other VMs are already running and other icons have been added to the system tray, changing the setting in Control Panel will not affect these icons. The setting will only affect the icon behavior if the VM is started afterwards.

Show Exception Dialog Box

Show an exception dialog box when exceptions occur. The default setting is hide the exception dialog box (unchecked).

Advanced Panel

The Advanced panel looks like this:

Use the Advanced panel to set the following options:

Java Runtime Environment

Enables Java Plug-in to run with any Java 2 JRE or SDK, Standard Edition v 1.4 installed on your machine. Java Plug-in 1.4 is delivered with a default JRE. However, you can override the default JRE and use an older or newer version in the 1.4 family. The Control Panel automatically detects all versions of the Java 2 SDK or JRE installed on your machine, and it displays in a list box all versions which you can use. The first item in the list will always be the Java Plug-in default; the last item will always say Other. If you choose Other, you must specify the path to the Java 2 JRE or SDK, Standard Edition v 1.4 that you wish to use. Only advanced users should change this option.

Only advanced users should change this option. Changing the default JRE is not recommended.

Java Runtime Parameters

You can override the Java Plug-in default startup parameters by specifying custom options in the Java Runtime Parameters field. The syntax is the same as used with parameters to the java command line invocation. See the Java 2 Standard Edition (J2SE) documentation for a full list of command line options. The URL below is subject to change:

is one of the operating systems: solaris, linux, windows.

Below are some examples of Java runtime parameters

Enabling and disabling assertion support

To enable assertion support, the following system property must be specified in the Java Runtime Parameters:

To disable assertion in the Java Plug-in, specify the following in the Java Runtime Parameters:

Assertion is disabled in Java Plug-in code by default. Since the effect of assertion is determined during Java Plug-in startup, changing assertion settings in the Java Plug-in Control Panel will require a browser restart in order for the new settings to take effect.

Because Java code in Java Plug-in also has built-in assertion, it is possible to enable the assertion in Java Plug-in code through the following:

Tracing and logging support

Tracing is a facility to redirect any output in the Java Console to a trace file ( .plugin .trace ).

If you do not want to use the default trace file name:

Similar to tracing, logging is a facility to redirect any output in the Java Console to a log file (.plugin .log ) using the Java Logging API. Logging can be turned on by enabling the property javaplugin.logging .

If you do not want to use the default log file name, enter:

Furthermore, if you do not want to overwrite the trace and log files each session, you can set the property:

If the property is set to false , then trace and log files will be uniquely named for each session. If the default trace and log file names are used, then the files would be named as follows

Tracing and logging set through the Control Panel will take effect when the Plug-in is launched, but changes made through the Control Panel while a Plug-in is running will have no effect until a restart.

For more information about tracing and logging, see the chapter called Tracing and Logging.

Debugging applets in Java Plug-in

The following options are used when debugging applets in the Java Plug-in. For more information on this topic see the Debugging Support in the Java Plug-in Developer Guide.

-Djava.compiler=NONE
-Xnoagent
-Xdebug
-Xrunjdwp:transport=dt_shmem,address= ,server=y,suspend=n

The can be any string (example: 2502 ) which is used by the Java Debugger ( jdb ) later to connect to the JVM

Default connection timeout

When a connection is made by an applet to a server and the server doesn’t respond properly, the applet may appear to hang and may also cause the browser to hang because, since by default there is no network connection timeout.

To avoid this problem, Java Plug-in 1.4 has added a default network timeout value (2 minutes) for all HTTP connections. You can override this setting in the Java Runtime Parameters:

Another networking property that you can set is sun.net.client.defaultReadTimeout .

Java Plug-in does not set sun.net.client.defaultReadTimeout by default. If you want to set it, do so through the Java Runtime Parameters as shown above.

Networking properties description:

These properties specify, respectively, the default connect and read timeout values for the protocol handlers used by java.net.URLConnection . The default values set by the protocol handlers is -1 , which means there is no timeout set.

sun.net.client.defaultConnectTimeout specifies the timeout (in milliseconds) to establish the connection to the host. For example, for http connections it is the timeout when establishing the connection to the http server. For ftp connections it is the timeout when establishing the connection to ftp servers.

sun.net.client.defaultReadTimeout specifies the timeout (in milliseconds) when reading from an input stream when a connection is established to a resource.

For the official description of these properties, see Networking Properties.

Browser Panel

This panel relates only to Microsoft Windows installations; it does not appear in other installations. Check any browser for which you want Java Plug-in to be the default Java runtime, instead of the internal JVM of that browser. This is to enable APPLET tag support in Internet Explorer and Netscape 6 via Java Plug-in.

Proxies Panel

The Proxies panel looks like this:

Use the Proxies panel to use the browser default settings or to override the proxy address and port for the different protocols.

Use browser settings

Check this to use the browser default proxy settings. This is the default setting (checked).

Proxy information table

You can override the default settings by unchecking the «Use browser settings» check box, then completing the proxy information table beneath the check box. You can enter the proxy address and port for each of the supported protocols: HTTP, Secure (HTTPS), FTP, Gopher, and Socks.

No proxy host

This is a host or list of hosts for which no proxy/proxies are to be used. No proxy host is usually used for an internal host in an intranet environment.

Automatic proxy configuration URL

This is the URL for the JavaScript file (.js or .pac extension) that contains the FindProxyForURL function. FindProxyForURL has the logic to determine the proxy server to use for a connection request.

For additional details about proxy configuration, see the chapter called Proxy Configuration.

Cache Panel

The Cache panel looks like this:

The cache referred to here is the sticky cache; i.e., the disk cache created and controlled by Java Plug-in which the browser cannot overwrite. See Applet Caching.

Enable Caching

Check this to enable caching. This the default setting (checked). With applet caching enabled, performance is improved because once an applet is cached it no longer needs to be downloaded when referenced again.

The Java Plug-in caches files of the following types downloaded via HTTP/HTTPS:

.jar (jar file)
.zip (zip file)
.class (java class file)
.au (audio file)
.wav (audio file)
.jpg (image file)
.gif (image file)

View files in Cache

Press this to view the cached files. Another dialog (Java Plug-in Cache Viewer) will pop up and display the cached files. The Cache Viewer displays the following information about the files in cache: Name, Type, Size, Expire Date, Last Modified, Version, and URL. In the Cache Viewer you can also selectively delete files in the cache. This is an alternative to the Clear Cache option described below, which deletes all files in the cache.

Clear Cache

Press this to clear all files in the cache. You will be prompted (Erase all files in . _cache?) before the files are removed.

Location

You can use this to specify the location of the cache. The default location of the cache is /.jpi_cache , where is the value of the system property user.home . Its value depends on the OS.

You can check Unlimited to make the cache unlimited in size; or you can set the Maximum size of the cache. If the cache size exceeds the specified limit, the oldest files cached will be removed until the cache size is within the limit.

Compression

You can set the compression of the JAR cache files between None and High. While you will save memory by specifying higher compression, performance will be degraded; best performance will be achieved with no compression.

Certificates Panel

The Certificates panel looks like this:

Four types of certificates may be selected:

Signed applet

These are certificates for signed applets that are trusted by the user. The certificates that appear in the signed applet list are read from the certificate file jpicerts located in the /.java directory.

Secure site

These are certificates for secure sites. The certificates that appear in the Secure site list are read from the certificate file jpihttpscerts located in the /.java directory.

Signer CA

These are certificates of Certificate Authorities (CAs) for signed applets; they are the ones who issue the certificates to the signers of signed applets. The certificates that appear in the Signer CA list are read from the certificate file cacerts , located in the /lib/security directory.

Secure site CA

These are certificates of Certificate Authorities (CAs) for secure sites; they are the ones who issue the certificates for secure sites. The certificates that appear in the Secure site CA list are read from the certificate file jssecacerts , located in the /lib/security directory

For Signed applet and Secure site certificates, there are four options: Import, Export, Remove, and Detail. The user can import, export, remove and view the details of a certificate.

For Signer CA and Secure site CA, there is only one option: Detail. The user can only view the details of a certificate.

Update Panel

The functionality described below for the Update panel is not available in the Beta release.

The Update panel looks like this:

The Update panel is for providing the latest Java update to end users.

To get the update, click on the Get Java Update button. The browser will be launched and point to:

The page will provide instructions and a link to the update binary if available. Download the update binary and double-click it.

Java Update will be launched. It will search the JRE on your system and apply the fix transparently. After the fix is applied, it will tell you so.

Читайте также:  Облако dahua для windows
Оцените статью