### Minimal HTTP Server Example Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.httpserver/com/sun/net/httpserver/package-summary.html A basic example demonstrating how to create and start an HTTP server with a custom handler for a specific context. ```APIDOC ## Minimal HTTP Server Example ### Description This example shows how to set up a simple HTTP server that listens on port 8000 and handles requests to the `/applications/myapp` path using a custom `HttpHandler`. ### Method N/A (Server setup) ### Endpoint N/A (Server setup) ### Parameters N/A ### Request Body N/A ### Response N/A ### Code Example ```java class MyHandler implements HttpHandler { public void handle(HttpExchange t) throws IOException { InputStream is = t.getRequestBody(); // read(is); // .. read the request body String response = "This is the response"; t.sendResponseHeaders(200, response.length()); OutputStream os = t.getResponseBody(); os.write(response.getBytes()); os.close(); } } HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); server.createContext("/applications/myapp", new MyHandler()); server.setExecutor(null); // creates a default executor server.start(); ``` ``` -------------------------------- ### Example of starting a process pipeline Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html Demonstrates how to create a pipeline of processes using ProcessBuilder. This example counts unique imports in Java files within a directory on a Unix-like system. ```Java String directory = "/home/duke/src"; ProcessBuilder[] builders = { new ProcessBuilder("find", directory, "-type", "f"), new ProcessBuilder("xargs", "grep", "-h", "^import "), new ProcessBuilder("awk", "{print $2;}") }; ``` -------------------------------- ### Example: Filtering rows starting with 'a' Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/RowFilter.html This example demonstrates how to create a RowFilter that includes rows where at least one column's string value starts with the letter 'a'. ```APIDOC ## Example: Filtering rows starting with 'a' ```java RowFilter startsWithAFilter = new RowFilter() { public boolean include(Entry entry) { for (int i = entry.getValueCount() - 1; i >= 0; i--) { if (entry.getStringValue(i).startsWith("a")) { // The value starts with "a", include it return true; } } // None of the columns start with "a"; return false so that this // entry is not shown return false; } }; ``` ``` -------------------------------- ### MonitorMBean.start() Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-19.html Starts the monitor. ```APIDOC ## MonitorMBean.start() ### Description Starts the monitor. ### Method `start()` ### Endpoint N/A (Java Method) ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### Get Recording Start Time Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jfr/jdk/jfr/Recording.html Returns the Instant when the recording was started. Returns null if the recording has not yet been started. ```Java public Instant getStartTime() ``` -------------------------------- ### Get Document Start Position Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/text/Document.html Method signature to retrieve the starting position of the document. ```java Position getStartPosition() ``` -------------------------------- ### Starting a Simple Process Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html Starts a new operating system process with a specified command and arguments using the default working directory and environment. ```java Process p = new ProcessBuilder("myCommand", "myArg").start(); ``` -------------------------------- ### Get Total Started Thread Count Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.management/java/lang/management/ThreadMXBean.html Retrieves the total number of platform threads created and started since JVM start. Excludes virtual threads. ```java long getTotalStartedThreadCount() Returns the total number of platform threads created and also started since the Java virtual machine started. The count does not include virtual threads. ``` -------------------------------- ### setupMenuOpenKey Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-19.html Sets up the menu open key for BasicInternalFrameUI. ```APIDOC ## Method: setupMenuOpenKey ### Description Setup the menu open key. ``` -------------------------------- ### Get Installed Configuration Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/security/auth/login/LoginContext.html Retrieves the installed security configuration. This is used when a LoginContext is instantiated without a specific Configuration object. ```java config = Configuration.getConfiguration(); ``` -------------------------------- ### engineInit(KeyStore, char[]) Method Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/net/ssl/KeyManagerFactorySpi.html Initializes the KeyManagerFactorySpi with a KeyStore and password. ```APIDOC ## engineInit(KeyStore ks, char[] password) ### Description Initializes this factory with a source of key material. ### Method `protected abstract void engineInit(KeyStore ks, char[] password)` ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ### Throws - `KeyStoreException`: if this operation fails - `NoSuchAlgorithmException`: if the specified algorithm is not available from the specified provider. - `UnrecoverableKeyException`: if the key cannot be recovered ### See Also - `KeyManagerFactory.init(KeyStore, char[])` ``` -------------------------------- ### Install MaskFormatter on JFormattedTextField Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/text/MaskFormatter.html Installs the DefaultFormatter, which MaskFormatter extends, onto a JFormattedTextField. This is a standard setup procedure for using formatters. ```java formatter.install(ftf); ``` -------------------------------- ### Method Details: engineInit(KeyStore ks) Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/net/ssl/TrustManagerFactorySpi.html Detailed explanation of the engineInit method that initializes the factory with a KeyStore. ```APIDOC ## Method Details ### engineInit `protected abstract void engineInit(KeyStore ks) throws KeyStoreException` Initializes this factory with a source of certificate authorities and related trust material. Parameters: `ks` - the key store or null Throws: `KeyStoreException` - if this operation fails See Also: * `TrustManagerFactory.init(KeyStore)` ``` -------------------------------- ### getOffset() - DefaultStyledDocument.ElementSpec Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Gets the starting offset for a DefaultStyledDocument.ElementSpec. ```APIDOC ## getOffset() ### Description Gets the starting offset. ### Method `getOffset()` ### Class `javax.swing.text.DefaultStyledDocument.ElementSpec` ``` -------------------------------- ### POST /start Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.management.rmi/javax/management/remote/rmi/RMIConnectorServer.html Activates the connector server to start listening for client connections. ```APIDOC ## POST /start ### Description Activates the connector server, that is starts listening for client connections. Calling this method when the connector server is already active has no effect. ### Errors - **IOException** - If the connector server has been stopped or cannot be started. ``` -------------------------------- ### Monitor.start() Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-19.html Starts the monitor. ```APIDOC ## Monitor.start() ### Description Starts the monitor. ### Method `start()` ### Endpoint N/A (Java Method) ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### getConfiguration() - javax.security.auth.login.Configuration Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Get the installed login Configuration. ```APIDOC ## getConfiguration() ### Description Get the installed login Configuration. ### Method Static method ### Class javax.security.auth.login.Configuration ``` -------------------------------- ### Example Properties File Lines Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Properties.html Illustrates valid syntax for key-value pairs in a properties file, including whitespace handling and escape sequences. ```properties Truth = Beauty Truth:Beauty Truth :Beauty ``` ```properties fruits apple, banana, pear, \ cantaloupe, watermelon, \ kiwi, mango ``` ```properties cheeses ``` -------------------------------- ### Instantiating KeyStore with a File Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/KeyStore.html This snippet shows how to get a KeyStore instance by specifying an existing keystore file. The system will probe the file to determine its type and load its entries. ```APIDOC ## Instantiating KeyStore with a File ### Description Obtain a `KeyStore` instance by providing a file path. The keystore's type is automatically detected from the file, and its entries are loaded upon instantiation. ### Method `KeyStore.getInstance(File keystoreFile, char[] password)` ### Parameters #### Path Parameters - **keystoreFile** (File) - Required - The file representing the keystore. - **password** (char[]) - Required - The password to access the keystore. ### Request Example ```java // get keystore password char[] password = getPassword(); // probe the keystore file and load the keystore entries KeyStore ks = KeyStore.getInstance(new File("keyStoreName"), password); ``` ``` -------------------------------- ### GET /instant/nano Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/time/Instant.html Retrieves the number of nanoseconds from the start of the second. ```APIDOC ## GET /instant/nano ### Description Gets the number of nanoseconds, later along the time-line, from the start of the second. ### Method GET ### Response #### Success Response (200) - **nanoseconds** (int) - The nanoseconds within the second, always positive, never exceeds 999,999,999 ``` -------------------------------- ### getStartOffset() - javax.swing.text.Highlighter.Highlight Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Gets the starting model offset for the highlight. ```APIDOC ## getStartOffset() ### Description Gets the starting model offset for the highlight. ### Method Method ### Interface `javax.swing.text.Highlighter.Highlight` ``` -------------------------------- ### Configuring and Starting a Process with Redirected I/O Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html Demonstrates how to configure a ProcessBuilder with a modified environment, working directory, and redirects standard output and error to a log file. It also shows how to enable error stream merging. ```java ProcessBuilder pb = new ProcessBuilder("myCommand", "myArg1", "myArg2"); Map env = pb.environment(); env.put("VAR1", "myValue"); env.remove("OTHERVAR"); env.put("VAR2", env.get("VAR1") + "suffix"); pb.directory(new File("myDir")); File log = new File("log"); pb.redirectErrorStream(true); pb.redirectOutput(Redirect.appendTo(log)); Process p = pb.start(); assert pb.redirectInput() == Redirect.PIPE; assert pb.redirectOutput().file() == log; ``` -------------------------------- ### List and Use JFR Configurations Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jfr/jdk/jfr/Configuration.html Demonstrates how to list available JFR configurations and how to pass a configuration object to a Recording. This example shows iterating through configurations and starting a recording with a specified configuration. ```java public static void main(String... args) throws Exception { if (args.length == 0) { System.out.println("Configurations:"); for (Configuration c : Configuration.getConfigurations()) { System.out.println("Name: " + c.getName()); System.out.println("Label: " + c.getLabel()); System.out.println("Description: " + c.getDescription()); System.out.println("Provider: " + c.getProvider()); System.out.println(); } } else { String name = args[0]; Configuration c = Configuration.getConfiguration(name); try (Recording r = new Recording(c)) { System.out.println("Starting recording with settings:"); for (Map.Entry setting : c.getSettings().entrySet()) { System.out.println(setting.getKey() + " = " + setting.getValue()); } r.start(); } } } ``` -------------------------------- ### getStartOffset() - javax.swing.text.AbstractDocument.LeafElement Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Gets the starting offset in the model for the element. ```APIDOC ## getStartOffset() ### Description Gets the starting offset in the model for the element. ### Method Method ### Class `javax.swing.text.AbstractDocument.LeafElement` ``` -------------------------------- ### Example Configuration Entry Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/security/auth/login/Configuration.html A concrete example of a configuration entry for an application named 'Login'. ```text Login { com.sun.security.auth.module.UnixLoginModule required; com.sun.security.auth.module.Krb5LoginModule optional useTicketCache="true" ticketCache="${user.home}${/}tickets"; }; ``` -------------------------------- ### getStartOffset() - javax.swing.text.AbstractDocument.BranchElement Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Gets the starting offset in the model for the element. ```APIDOC ## getStartOffset() ### Description Gets the starting offset in the model for the element. ### Method Method ### Class `javax.swing.text.AbstractDocument.BranchElement` ``` -------------------------------- ### Recording.start() Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-19.html Starts this recording. ```APIDOC ## Recording.start() ### Description Starts this recording. ### Method `start()` ### Endpoint N/A (Java Method) ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### getStartOffset() - javax.swing.text.AbstractDocument.AbstractElement Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Gets the starting offset in the model for the element. ```APIDOC ## getStartOffset() ### Description Gets the starting offset in the model for the element. ### Method Method ### Class `javax.swing.text.AbstractDocument.AbstractElement` ``` -------------------------------- ### Getting the Start Position of a Document Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/text/AbstractDocument.html Retrieves a position object representing the beginning of the document. This position will remain at the start even as the document is modified. ```java public final Position getStartPosition() ``` -------------------------------- ### Starting a Process Pipeline Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html Demonstrates how to start a pipeline of processes using ProcessBuilder.startPipeline. The standard output of each process is connected to the standard input of the next, and the standard output of the last process is captured. ```Java ProcessBuilder[] builders = { new ProcessBuilder("sort", "-u") }; List processes = ProcessBuilder.startPipeline( Arrays.asList(builders)); Process last = processes.get(processes.size()-1); try (InputStream is = last.getInputStream(); Reader isr = new InputStreamReader(is); BufferedReader r = new BufferedReader(isr)) { long count = r.lines().count(); } ``` -------------------------------- ### Tool Description Overview Example Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/spi/ToolProvider.html Example format for displaying tool names and their descriptions in a concise overview. ```text jar Create, manipulate, and extract an archive of classes and resources. javac Read Java declarations and compile them into class files. jlink Assemble a set of modules (...) into a custom runtime image. ``` -------------------------------- ### EventStream Usage Example Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jfr/jdk/jfr/consumer/EventStream.html This example demonstrates how to use the EventStream to listen for specific events like 'jdk.CPULoad' and 'jdk.GarbageCollection', process them, and start the stream. ```APIDOC ## EventStream Usage Example ### Description This example demonstrates how to use the EventStream to listen for specific events like 'jdk.CPULoad' and 'jdk.GarbageCollection', process them, and start the stream. ### Code ```java try (var es = EventStream.openRepository()) { es.onEvent("jdk.CPULoad", event -> { System.out.println("CPU Load " + event.getEndTime()); System.out.println(" Machine total: " + 100 * event.getFloat("machineTotal") + "%\n"); System.out.println(" JVM User: " + 100 * event.getFloat("jvmUser") + "%\n"); System.out.println(" JVM System: " + 100 * event.getFloat("jvmSystem") + "%\n"); System.out.println(); }); es.onEvent("jdk.GarbageCollection", event -> { System.out.println("Garbage collection: " + event.getLong("gcId") + "\n"); System.out.println(" Cause: " + event.getString("cause") + "\n"); System.out.println(" Total pause: " + event.getDuration("sumOfPauses") + "\n"); System.out.println(" Longest pause: " + event.getDuration("longestPause") + "\n"); System.out.println(); }); es.start(); } ``` ``` -------------------------------- ### Get Thread Start Requests Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jdi/com/sun/jdi/request/EventRequestManager.html Returns an unmodifiable, live view of all enabled and disabled thread start requests. Changes to the requests are reflected in this list. ```java List threadStartRequests() ``` -------------------------------- ### KeyStore Instantiation Methods Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/class-use/KeyStore.html Methods for creating and retrieving KeyStore instances. ```APIDOC ## KeyStore.getInstance ### Description Returns a KeyStore object of the specified type or loaded from a file. ### Methods - KeyStore.getInstance(File file, char[] password) - KeyStore.getInstance(File file, KeyStore.LoadStoreParameter param) - KeyStore.getInstance(String type) - KeyStore.getInstance(String type, String provider) - KeyStore.getInstance(String type, Provider provider) ### Parameters - **type** (String) - The type of the keystore. - **file** (File) - The file to load the keystore from. - **password** (char[]) - The password for the keystore. - **provider** (String/Provider) - The security provider to use. ``` -------------------------------- ### Get Matcher Region Start Index Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/regex/Matcher.html Reports the starting index of the current region for this matcher. Searches are limited to the range defined by regionStart() and regionEnd(). ```java public int regionStart() ``` -------------------------------- ### setupMenuCloseKey Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-19.html Sets up the menu close key for BasicInternalFrameUI. ```APIDOC ## Method: setupMenuCloseKey ### Description Setup the menu close key. ``` -------------------------------- ### Get Specific Listeners from Choice Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/Choice.html Retrieves an array of listeners of a specified type registered on this Choice. For example, to get ItemListeners, use c.getListeners(ItemListener.class). ```Java public T[] getListeners(Class listenerType) ``` -------------------------------- ### Starting a New Process Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html Starts a new process based on the configuration of this ProcessBuilder. This method handles command execution, working directory, and environment setup. ```Java public Process start() throws IOException ``` -------------------------------- ### Starting a Process with ProcessBuilder Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html This snippet demonstrates how to start a new process using the ProcessBuilder. It configures the command and arguments for the process. ```Java Process p = new ProcessBuilder("myCommand", "arg1", "arg2") .redirectErrorStream(true) .start(); assert p.getInputStream().read() == -1; ``` -------------------------------- ### Configure LocaleServiceProvider Implementation Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/spi/LocaleServiceProvider.html Examples showing the required file path and content for registering a custom DateFormatProvider implementation. ```text META-INF/services/java.text.spi.DateFormatProvider ``` ```text com.foo.DateFormatProviderImpl ``` -------------------------------- ### GET /hasController Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/imageio/metadata/IIOMetadata.html Checks if a controller is currently installed for the IIOMetadata object. ```APIDOC ## GET /hasController ### Description Returns true if there is a controller installed for this IIOMetadata object. ### Method GET ### Response #### Success Response (200) - **boolean** (boolean) - true if a controller is installed, false otherwise. ``` -------------------------------- ### Create Step Request Example Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jdi/com/sun/jdi/request/EventRequestManager.html Demonstrates how to create a step request for a specific thread, line stepping, and stepping over. It also shows how to limit the request to a single step and enable it. ```java EventRequestManager mgr = myVM.{@link VirtualMachine#eventRequestManager eventRequestManager}(); StepRequest request = mgr.createStepRequest(myThread, StepRequest.{@link StepRequest#STEP_LINE STEP_LINE}, StepRequest.{@link StepRequest#STEP_OVER STEP_OVER}); request.{@link EventRequest#addCountFilter addCountFilter}(1); // next step only request.enable(); myVM.{@link VirtualMachine#resume resume}(); ``` -------------------------------- ### GET /getFromPage Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/JobAttributes.html Retrieves the starting page number for the print range. ```APIDOC ## GET /getFromPage ### Description Returns the first page to be printed if a range is specified. ### Method GET ### Response #### Success Response (200) - **fromPage** (int) - An integer greater than zero and within valid page bounds ``` -------------------------------- ### init with KeyStore Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/net/ssl/KeyManagerFactory.html Initializes the KeyManagerFactory with a KeyStore and password. ```APIDOC ## POST /api/keymanagerfactory/init/keystore ### Description Initializes this factory with a source of key material using a KeyStore and password. ### Method POST ### Endpoint /api/keymanagerfactory/init/keystore ### Parameters #### Request Body - **ks** (KeyStore) - Required - The key store or null. - **password** (char[]) - Required - The password for recovering keys in the KeyStore. ### Request Example ```json { "ks": "myKeyStore.jks", "password": "myPassword" } ``` ### Response #### Success Response (200) - **message** (string) - Initialization successful. #### Error Response (400) - **error** (string) - `KeyStoreException`, `NoSuchAlgorithmException`, or `UnrecoverableKeyException` if initialization fails. ``` -------------------------------- ### GET /installedProviders Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/spi/FileSystemProvider.html Returns a list of the installed file system providers. ```APIDOC ## GET /installedProviders ### Description Returns a list of the installed file system providers. The first invocation causes the default provider to be initialized. ### Method GET ### Endpoint /installedProviders ### Response #### Success Response (200) - **List** - An unmodifiable list of the installed file system providers. ``` -------------------------------- ### Example Usage Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.httpserver/com/sun/net/httpserver/HttpsConfigurator.html Example demonstrating how to override the configure method to change default HTTPS configuration. ```APIDOC ```java SSLContext sslContext = SSLContext.getInstance (....); HttpsServer server = HttpsServer.create(); server.setHttpsConfigurator (new HttpsConfigurator(sslContext) { public void configure (HttpsParameters params) { // get the remote address if needed InetSocketAddress remote = params.getClientAddress(); SSLContext c = getSSLContext(); // get the default parameters SSLParameters sslparams = c.getDefaultSSLParameters(); if (remote.equals (...) ) { // modify the default set for client x } params.setSSLParameters(sslparams); } }); ``` ``` -------------------------------- ### Get Text Start Position Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.xml/javax/xml/stream/XMLStreamReader.html Retrieves the starting offset of the text within the character array for the current text event. This method is only valid for text-related events. ```Java int getTextStart() ``` -------------------------------- ### Example Keystore Domain Configuration Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/DomainLoadStoreParameter.html An example demonstrating a keystore domain named 'app1' with three distinct keystores: 'app1-truststore', 'system-truststore', and 'app1-keystore'. Each keystore has its URI and type specified. ```plaintext domain app1 { keystore app1-truststore keystoreURI="file:///app1/etc/truststore.jks"; keystore system-truststore keystoreURI="${java.home}/lib/security/cacerts"; keystore app1-keystore keystoreType="PKCS12" keystoreURI="file:///app1/etc/keystore.p12"; }; ``` -------------------------------- ### GET position() Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/Blob.html Finds the starting position of a byte pattern within the BLOB. ```APIDOC ## GET position() ### Description Retrieves the byte position at which the specified byte array pattern begins within the BLOB value. ### Parameters #### Query Parameters - **pattern** (byte[]) - Required - The byte array to search for. - **start** (long) - Required - The position at which to begin the search. ``` -------------------------------- ### GET /locales/available Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Locale.html Retrieves a list of all installed locales available in the Java environment. ```APIDOC ## GET /locales/available ### Description Returns a list of installed locales available in the current Java runtime environment. ### Method GET ### Endpoint /locales/available ### Response #### Success Response (200) - **locales** (Array) - A list of available Locale objects or strings representing installed locales. #### Response Example [ "en-US", "fr-FR", "ja-JP" ] ``` -------------------------------- ### KeyStore Initialization and Usage Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/class-use/KeyStore.html Methods for initializing factories and parameters using a KeyStore. ```APIDOC ## KeyStore Initialization ### Description Methods to initialize KeyManagerFactory, TrustManagerFactory, and PKIX parameters using a KeyStore. ### Methods - KeyManagerFactory.init(KeyStore ks, char[] password) - TrustManagerFactory.init(KeyStore ks) - PKIXParameters(KeyStore keystore) - PKIXBuilderParameters(KeyStore keystore, CertSelector targetConstraints) ### Parameters - **ks** (KeyStore) - The source of key or trust material. - **password** (char[]) - The password for the key material. ``` -------------------------------- ### Create and Populate Hashtable in Java Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Hashtable.html Demonstrates how to create a Hashtable instance and add key-value pairs. Ensure keys are non-null and implement hashCode and equals. ```java Hashtable = new Hashtable(); numbers.put("one", 1); numbers.put("two", 2); numbers.put("three", 3); ``` -------------------------------- ### GET /providers/filter Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/Security.html Retrieves installed providers that satisfy a specific selection criterion. ```APIDOC ## GET /providers/filter ### Description Returns an array containing all installed providers that satisfy the specified selection criterion, or null if no such providers have been installed. ### Method GET ### Endpoint /providers/filter ### Parameters #### Query Parameters - **filter** (String) - Required - The criterion for selecting providers (e.g., "CertificateFactory.X.509"). ### Response #### Success Response (200) - **providers** (Provider[]) - All the installed providers that satisfy the selection criterion. ``` -------------------------------- ### Method Handle Creation and Invocation Examples Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/invoke/MethodHandle.html Demonstrates creating method handles for virtual, static, and generic methods, and invoking them using both exact and weakly typed methods. Includes examples of type conversion and checking for varargs collectors. ```java Object x, y; String s; int i; MethodType mt; MethodHandle mh; MethodHandles.Lookup lookup = MethodHandles.lookup(); // mt is (char,char)String mt = MethodType.methodType(String.class, char.class, char.class); mh = lookup.findVirtual(String.class, "replace", mt); s = (String) mh.invokeExact("daddy",'d','n'); // invokeExact(Ljava/lang/String;CC)Ljava/lang/String; assertEquals(s, "nanny"); // weakly typed invocation (using MHs.invoke) s = (String) mh.invokeWithArguments("sappy", 'p', 'v'); assertEquals(s, "savvy"); // mt is (Object[])List mt = MethodType.methodType(java.util.List.class, Object[].class); mh = lookup.findStatic(java.util.Arrays.class, "asList", mt); assert(mh.isVarargsCollector()); x = mh.invoke("one", "two"); // invoke(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object; assertEquals(x, java.util.Arrays.asList("one","two")); // mt is (Object,Object,Object)Object mt = MethodType.genericMethodType(3); mh = mh.asType(mt); x = mh.invokeExact((Object)1, (Object)2, (Object)3); // invokeExact(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; assertEquals(x, java.util.Arrays.asList(1,2,3)); // mt is ()int mt = MethodType.methodType(int.class); mh = lookup.findVirtual(java.util.List.class, "size", mt); i = (int) mh.invokeExact(java.util.Arrays.asList(1,2,3)); // invokeExact(Ljava/util/List;)I assert(i == 3); mt = MethodType.methodType(void.class, String.class); mh = lookup.findVirtual(java.io.PrintStream.class, "println", mt); mh.invokeExact(System.out, "Hello, world."); // invokeExact(Ljava/io/PrintStream;Ljava/lang/String;)V ``` -------------------------------- ### GET /providers Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/Security.html Retrieves an array of all installed security providers ordered by preference. ```APIDOC ## GET /providers ### Description Returns an array containing all the installed providers. The order of the providers in the array is their preference order. ### Method GET ### Endpoint /providers ### Response #### Success Response (200) - **providers** (Provider[]) - An array of all the installed providers. ``` -------------------------------- ### KeyStoreLoginModule.initialize Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/security/auth/callback/class-use/CallbackHandler.html Initializes the KeyStoreLoginModule with a Subject, CallbackHandler, shared state, and options. ```APIDOC ## KeyStoreLoginModule.initialize ### Description Initialize this `LoginModule`. ### Method Signature `void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options)` ``` -------------------------------- ### getRequestingScheme() Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example). ```APIDOC ## getRequestingScheme() ### Description Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example). ### Method `getRequestingScheme()` ### Class `java.net.Authenticator` ``` -------------------------------- ### Get Thread CPU Time (Example Usage) Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.management/java/lang/management/ThreadMXBean.html Demonstrates how to get the CPU time for a specific thread using its ID. This is equivalent to calling getCurrentThreadCpuTime for the current thread. ```Java getThreadCpuTime(Thread.currentThread().threadId()); ``` -------------------------------- ### Create KeyInfo Instance Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.xml.crypto/javax/xml/crypto/dsig/keyinfo/KeyInfo.html Demonstrates creating a KeyInfo instance using the KeyInfoFactory. ```java KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM"); KeyInfo keyInfo = factory.newKeyInfo (Collections.singletonList(factory.newKeyName("Alice"), "keyinfo-1")); ``` -------------------------------- ### Desktop.open(File) Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-15.html Launches the associated application to open the file. ```APIDOC ## Desktop.open(File) ### Description Launches the associated application to open the file. ### Method Instance Method ### Endpoint N/A (Method Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Set Daylight Saving Time Start Rule (Detailed) Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/SimpleTimeZone.html Sets the daylight saving time start rule using month, day, day of week, and start time. Example shows setting DST to start on the first Sunday in April at 2 AM local wall clock time. ```java setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000); ``` ```java public void setStartRule(int startMonth, int startDay, int startDayOfWeek, int startTime) ``` -------------------------------- ### engineInit Method Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/crypto/MacSpi.html Initializes the MAC with a secret key and algorithm parameters. ```APIDOC ## Method: engineInit(Key key, AlgorithmParameterSpec params) ### Description Initializes the MAC with the given (secret) key and algorithm parameters. ### Signature `protected abstract void engineInit(Key key, AlgorithmParameterSpec params)` ### Parameters * `key` (Key) - The (secret) key. * `params` (AlgorithmParameterSpec) - The algorithm parameters. ### Throws * `InvalidKeyException` - If the given key is inappropriate for initializing this MAC. * `InvalidAlgorithmParameterException` - If the given algorithm parameters are inappropriate for this MAC. ``` -------------------------------- ### Desktop.browse Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/class-use/IOException.html Launches the default browser to display a URI. ```APIDOC ## POST Desktop.browse ### Description Launches the default browser to display a URI. ### Method POST ### Parameters #### Request Body - **uri** (URI) - Required - The URI to be displayed. ``` -------------------------------- ### Attach, Start Management Agent, and Detach Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.attach/com/sun/tools/attach/VirtualMachine.html This example demonstrates attaching to a target VM by its process ID, starting the JMX management agent with specified properties, and then detaching from the VM. ```java // attach to target VM VirtualMachine vm = VirtualMachine.attach("2177"); // start management agent Properties props = new Properties(); props.put("com.sun.management.jmxremote.port", "5000"); vm.startManagementAgent(props); // detach vm.detach(); ``` -------------------------------- ### Initialize and Execute JdbcRowSet Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.sql.rowset/javax/sql/rowset/JdbcRowSet.html Demonstrates creating a JdbcRowSetImpl instance, configuring database connection properties, setting query parameters, and executing the command. ```java JdbcRowSetImpl jrs = new JdbcRowSetImpl(); jrs.setCommand("SELECT * FROM TITLES WHERE TYPE = ?"); jrs.setURL("jdbc:myDriver:myAttribute"); jrs.setUsername("cervantes"); jrs.setPassword("sancho"); jrs.setString(1, "BIOGRAPHY"); jrs.execute(); ``` -------------------------------- ### Get Scanline Stride in SinglePixelPackedSampleModel Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/image/SinglePixelPackedSampleModel.html Returns the scanline stride of the SinglePixelPackedSampleModel. The scanline stride represents the number of data elements between the start of one scanline and the start of the next in the DataBuffer. ```java public int getScanlineStride() ``` -------------------------------- ### AWTKeyStroke String Parsing Examples Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/java/awt/AWTKeyStroke.html Examples of string inputs and their corresponding AWTKeyStroke method calls. ```text "INSERT" => getAWTKeyStroke(KeyEvent.VK_INSERT, 0); "control DELETE" => getAWTKeyStroke(KeyEvent.VK_DELETE, InputEvent.CTRL_MASK); "alt shift X" => getAWTKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK); "alt shift released X" => getAWTKeyStroke(KeyEvent.VK_X, InputEvent.ALT_MASK | InputEvent.SHIFT_MASK, true); "typed a" => getAWTKeyStroke('a'); ``` -------------------------------- ### GET /classloading/unloaded-class-count Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.management/java/lang/management/ClassLoadingMXBean.html Retrieves the total number of classes unloaded since the JVM started. ```APIDOC ## GET /classloading/unloaded-class-count ### Description Returns the total number of classes unloaded since the Java virtual machine has started execution. ### Method GET ### Response #### Success Response (200) - **count** (long) - The total number of unloaded classes. ``` -------------------------------- ### Initialize Server-Side GSSContext Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.security.jgss/org/ietf/jgss/GSSManager.html Demonstrates acquiring server credentials and initializing a security context to accept incoming requests. ```java // Acquire credentials for the server GSSCredential serverCreds = manager.createCredential(serverName, GSSCredential.DEFAULT_LIFETIME, krb5Mechanism, GSSCredential.ACCEPT_ONLY); // Instantiate and initialize a security context that will // wait for an establishment request token from the client GSSContext context = manager.createContext(serverCreds); ``` -------------------------------- ### GET /classloading/total-loaded-class-count Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.management/java/lang/management/ClassLoadingMXBean.html Retrieves the total number of classes loaded since the JVM started. ```APIDOC ## GET /classloading/total-loaded-class-count ### Description Returns the total number of classes that have been loaded since the Java virtual machine has started execution. ### Method GET ### Response #### Success Response (200) - **count** (long) - The total number of classes loaded. ``` -------------------------------- ### start Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/ProcessBuilder.html Starts a new process using the attributes of this process builder. The new process will invoke the command and arguments given by command(), in a working directory as given by directory(), with a process environment as given by environment(). ```APIDOC ## start ### Description Starts a new process using the attributes of this process builder. The new process will invoke the command and arguments given by `command()`, in a working directory as given by `directory()`, with a process environment as given by `environment()`. ### Method POST ### Endpoint /ProcessBuilder/start ### Throws - IOException - If an I/O error occurs. - UnsupportedOperationException - If the operating system does not support the creation of processes. ### Returns - Process - The new process ``` -------------------------------- ### GET /java.util/Locale/getAvailableLocales Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/class-use/Locale.html Retrieves an array of all installed locales available in the Java Virtual Machine. ```APIDOC ## GET /java.util/Locale/getAvailableLocales ### Description Returns an array of all installed locales. ### Method GET ### Endpoint Locale.getAvailableLocales() ### Response #### Success Response (200) - **Locale[]** (array) - An array of installed Locale objects. ``` -------------------------------- ### Configure and Launch Java Shell Tool Source: https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jshell/jdk/jshell/tool/package-summary.html Advanced usage demonstrating configuration of output streams, locale, and passing command-line arguments to the tool. ```java JavaShellToolBuilder .builder() .out(myCommandPrintStream, myOutputPrintStream) .locale(Locale.CANADA) .start("--feedback", "silent", "MyStart"); ``` -------------------------------- ### GET /list/listIterator Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/AbstractSequentialList.html Returns a list iterator over the elements in the list starting at the specified index. ```APIDOC ## GET /list/listIterator ### Description Returns a list iterator over the elements in this list in proper sequence. ### Parameters #### Query Parameters - **index** (int) - Required - Index of the first element to be returned from the list iterator. ### Response #### Success Response (200) - **listIterator** (ListIterator) - A list iterator over the elements in this list. ### Errors - **IndexOutOfBoundsException** - If the index is out of range. ``` -------------------------------- ### TimerMBean.start() Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-19.html Starts the timer. ```APIDOC ## TimerMBean.start() ### Description Starts the timer. ### Method `start()` ### Endpoint N/A (Java Method) ### Parameters None ### Request Example N/A ### Response N/A ``` -------------------------------- ### GET /DatabaseMetaData/isCatalogAtStart Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.sql/java/sql/class-use/SQLException.html Retrieves whether a catalog appears at the start of a fully qualified table name. ```APIDOC ## GET /DatabaseMetaData/isCatalogAtStart ### Description Retrieves whether a catalog appears at the start of a fully qualified table name. ### Method GET ### Response #### Success Response (200) - **result** (boolean) - Returns true if catalog is at the start, false otherwise. ``` -------------------------------- ### getSelectionStart() - TextComponent.AccessibleAWTTextComponent Source: https://docs.oracle.com/en/java/javase/21/docs/api/index-files/index-7.html Gets the starting offset of the selected text within an accessible text component. ```APIDOC ## getSelectionStart() - TextComponent.AccessibleAWTTextComponent ### Description Returns the start offset within the selected text. ### Method `getSelectionStart()` ### Endpoint N/A (Java Method) ``` -------------------------------- ### Hashtable Usage Examples Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Hashtable.html Code examples demonstrating how to create and use a Hashtable in Java. ```APIDOC ## Usage Examples ### Creating and Populating a Hashtable ```java Hashtable numbers = new Hashtable(); numbers.put("one", 1); numbers.put("two", 2); numbers.put("three", 3); ``` ### Retrieving a Value from a Hashtable ```java Integer n = numbers.get("two"); if (n != null) { System.out.println("two = " + n); } ``` ``` -------------------------------- ### Setting JVM-wide Filter via Command Line Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/io/ObjectInputFilter.html A JVM-wide filter can be set using a system property on the command line. This example allows classes starting with 'example.' and 'java.base', and rejects all others. ```bash % java -Djdk.serialFilter="example.*;java.base/*;!*" ... ``` -------------------------------- ### init(Key key) Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/crypto/KeyAgreement.html Initializes this key agreement with the given key, which is required to contain all the algorithm parameters required for this key agreement. ```APIDOC ## Method: init(Key key) ### Description Initializes this key agreement with the given key. ### Parameters * `key` (Key) - the key required to contain all the algorithm parameters. ### Throws * `InvalidKeyException` - if the given key is invalid. ``` -------------------------------- ### Instantiating KeyStore with Default Type Source: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/KeyStore.html This snippet demonstrates how to obtain a KeyStore instance using the system's default keystore type. ```APIDOC ## Instantiating KeyStore with Default Type ### Description Get a `KeyStore` instance that uses the system's default keystore type. ### Method `KeyStore.getInstance(String type)` where type is `KeyStore.getDefaultType()` ### Parameters None directly for this method, relies on system default. ### Request Example ```java KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); ``` ```