Preskočiť na hlavný obsah

Príspevky

Zobrazujú sa príspevky so štítkom java

Java 24 Release - March 2025

Java 24 Release - March 2025 Oracle released Java 24 on March 18, 2025, as the latest version of the Java SE Platform. This release represents the Reference Implementation of Java SE Platform version 24 as specified by JSR 399 in the Java Community Process. Key Features: Stream Gatherers : A new enhancement that gives developers fine-grained control over how elements are grouped and processed within streams, making complex data transformations more expressive and efficient The final feature set includes 24 JEPs (Java Enhancement Proposals), with two being Generational Shen ( Java 24 New Experimental features ) Enhancements to the platform's performance, stability, and security to help organizations accelerate their business growth ( Oracle Releases Java 24 ) Java Release Schedule Updates - Java 25 LTS Oracle has confirmed that Java SE 8, 11, 17 and 21 are LTS (Long Term Support) releases, with Oracle intending to make future LTS releases every two years, meaning the next planned ...

Did you know that methods in Java have a size limit?

The JVM's method size limit of 64kB of bytecode is an important constraint for Java developers to understand. Here's more information about this limitation: JVM Method Size Limit The 65,535 (64K-1) byte limit on method bytecode is a fundamental constraint in the Java Virtual Machine (JVM) specification. This isn't about the number of lines of source code, but rather the compiled bytecode size of a single method. Why This Limit Exists This limit results from the JVM's internal design, specifically - how Java represents method code. The JVM uses a 16-bit unsigned index (u2) in the class file format to represent code length (2^16 = 65 536), but since indexing starts at 0, the maximum size is 65,535 bytes Common Causes of Large Methods Methods can grow unexpectedly large in bytecode due to, eg. complex logic with many branches and conditions. Methods can grow due to large switch statements, inlined code (especially from lambdas), string concatenation operations. Method refe...

What is the minimum app in Java (21)?

Who doesn't know "Hello, World!"? When you start writing a code in a new language, you usually write this simple program. What does it look like in Java code? class App { public static void main(String[] args) { System.out.println("Hello, World!"); } } But, explain to a beginner what "public static void" and strange args are. What would you say if the program could be simplified. class App { void main() { System.out.println("Hello, World!"); } } Let's make it even simpler, without class declaration. void main() { System.out.println("Hello, World!"); } Yes, this is simplest Java code in Java 21 release. Try it yourself. In a Java 21 preview feature (JEP 445) it needs to be enabled by with the --enable-preview flag. Just compile your application by command javac --release 21 --enable-preview App.java and run it as simple as java --enable-preview App This simplification i...

Will this Java code run?

Will this Java code run? The Test instance variable via the value() method returns null.  What about NullPointerException? Is it possible to access the pi member through null?

JavaOne is back!

In 2018 and 2019, the famous Java developer conference used the name Code One. For 2022, the name JavaOne is back again! The world's leading developer conference is scheduled to take place in Las Vegas at Oracle CloudWorld in October 2022. Oracle CloudWorld promises to keep you up-to-date on Java innovations in 2022. News on development tools, resources and best practices to accelerate the development and deployment of modern applications in cloud, mobile, local or hybrid environments.  JavaOne participants can choose from hundreds of profi seminars, labs, tutorials and other sessions. Sure, we’ll learn a lot about Java 18 and Java 19, which will be released in September 2022, and definitely we will learn more about the future of the Java platform. JavaOne will be within Oracle CloudWorld in Las Vegas, Nevada, f rom October 16 to October 22, 2022 .

Text Blocks

Od Java 15 sú textové bloky k dispozícii ako štandard. V Java 13 a 14 je potrebné túto feature povoliť (preview). Zatiaľ posledná verzia platformy Java je ver. 15, alebo keď chcete presnejšie JDK 15 rel. 2020-09-16. Posledná LTS (verzia dlhodobej podpory) bola JDK 11 zo septembra 2018. Text Blocks Aj vy máte problém s tým, keď máte dlhý String a potrebujete ho dať do premennej priamo v kóde? Samozrejme, riadok je potom dlhý a pretečie...  Vlastnosť Text Blocks umožňuje zápis textov (string reťazcov) na viac riadkov bez toho, aby ste ich museli spájať operátorom "+". Ide to veľmi jednoducho. Poďme sa na to pozrieť prakticky. Text Blocks  sú na začiatku a konci bloku označené trojitými úvodzovkami (""""). V takejto forme môžu obsahovať text rozdelený do viacerých riadkov bez potreby zadávať znak nového riadku \n. Java kompilátor je pri tejto novej funkcii tak trochu "smart" a snaží sa automaticky odstraňovať prebytočné biele znaky (medzery, tabulá...

Java 8 / did U know?

JavaScript engine Engine Nashorn replaces old one (Rhino) as the new default JavaScript engine for the Oracle jvm. Nashorn is faster. It uses the invokedynamic feature of the jvm. "jjs" is Nashorn command line tool. Optional 8 comes with the Optional class (java.util.Optional) for avoiding nulls (NullPointerException). It is very similar to Google’s Optional, which is similar to Nat Pryce’s Maybe or Scala’s Option class. Streams What is a Stream? Stream is a interface (java.util.stream.Stream) and represents a sequence of some objects. However, unlike the Iterator, it supports parallel execution. The Stream supports the map/filter/reduce design pattern and executes lazily, forming the basis (along with lambdas) for functional-style programming in Java 8. Example: // finding a maximum max = list.stream().reduce(0.0, Math::max);

Get Enum constant of an Enum by String

Method cast(Class, String) builds the enum value constant of the specified Enum. The name must match exactly (case) an identifier used to declare an enum constant in the given Enum. @SuppressWarnings({ "rawtypes", "unchecked" }) public static <E extends Enum<E>> E cast(String name, Class&lt;E> clazz) { if (clazz == null || name == null || name.isEmpty()) { return null; } try { return (E) Enum.valueOf((Class<Enum>) clazz, name); } catch (Throwable e) { throw new RuntimeException("Enum cast error: '" + name + "' in not valid value of '" + clazz.getName() + "'"); } }

JAVA 7: Underscores in Numeric Literals

In Java 7 an underscore characters (_) can be put anywhere between digits in a numeric literals.  If application code contains numbers with so many digits, you can use an underscore character to organize digits to the groups of three, four or as much as you want. This absolutly improves code readability. Examples: long myPayment   =  1_234_567L ; long phoneNumber = 0421_555_1234_5678L ; long niceColor   =  0x68_FE_A0 ; long someFlags   =  0b01101001_10010010 ; Rules for this feature  You can place underscore characters only between digits. You cannot place underscores in the following places: at the beginning or end of a number next to a decimal point in a floating point literal before an F or L suffix in positions where a string of digits is expected int n = _42; // WARNING! an identifier, not a literal! int n = 42_; // ERROR! underscores at the end of a literal float e = 2_.72; // ERROR! underscore...

Git

Git is a free and open source, distributed version control system designed to handle everything from small to very large projects. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do. Eclipse plugin:  http://www.jgit.org/updates

About Java

The java programming language is becoming more and more popular each day. It is the language without which one cannot even hope to a land a job these days. But has somebody even wondered how this language came about? There are many stories about, many books have been written. Here is my version (not approved by Sun Microsystems).

Lambda Expressions for Java

Lambda expressions are similar to anonymous methods introduced in C# 2.0, except that lambda expressions are more concise and more flexible. All lambda expressions use the lambda operator -> which is read as “goes to”. The left side of the lambda operator specifies the input parameters and the right side holds the expression or statement block. Here is an example of lambda expressions:   x  ->  x + 1 JSR 335: Lambda Expressions for the JavaTM Programming Language: Extend the Java language to support compact lambda expressions (closures), as well as related language and library features to enable the Java SE APIs to use lambda expressions effectively.

JDK 8

The goal of this Project is to to produce an open-source reference implementation of the Java SE 8 Platform, to be defined by JSR 337 in the Java Community Process. This Project is sponsored by the Build Group. History and status JDK 8 as presently conceived is the second part of Plan B. The proposed release-driver features are the Lambda and Jigsaw Projects. Additional features will be included, but they must fit into the schedule required for the release drivers. Now that work on JDK 7 is winding down, the next couple of months will be devoted to planning JDK 8 in detail. The proposed JEP Process will be a key part of this effort. Details on how Committers can participate in that process will be available shortly. Plan A: JDK 7 (as currently defined) Mid 2012 Plan B: JDK 7 (minus Lambda, Jigsaw, and part of Coin) Mid 2011 JDK 8 (Lambda, Jigsaw, the rest of Coin, ++) Late 2012

Spring Framework

Spring is a Java/J2EE application framework, based Rod Johnson's code on Expert One-on-One J2EE Design and Development. Spring's functionality can be used in any J2EE container, and most of it also in non-managed environments.

Java Serialization

Have you ever use serialization? Why and when is serialization required? Serialization is the process of storing an object's full state to a sequence of bytes. By deserializing the object you rebuild those bytes into a original object.

What is Java EE?

Java EE - Enterprise Edition - also known as J2EE, is a platform-independent, Java development environment for building and deploying not only Web-based enterprise applications. The Java EE platform consists of a set of APIs and protocols. Java EE also includes many components of the Java Standard Edition - SE. Java EE simplifies application development and reduces amount of work in design time by using standardized, reusable and modular components.

Jar's extended features

JARs are Java Archives. They can do much more than only store source your compilations. JARs, WARs and EARs, can hold extra informations to be useful later in the runtime.