Skip to content

Tag: java-16

Eclipse not able to see javax package

I’m currently trying to fiddle with images, specifically convert images from JPEG, WEBP, and BMP forms to PNG forms and my method uses the javax.imageio.ImageIO class. When I tried importing it, Eclipse yelled that the package that the type was not accessible. I thought that was weird and went digging through StackOverflow on my own and found multiple answers saying

How do I create a jar file via the command line?

Lets say I have these .java files: MainClass.java 2ndClass.java BarClass.java FooClass.java Then I turn them into .class files: MainClass.class 2ndClass.class BarClass.class FooClass.class How would I make it a jar file, and have MainClass.class be the first to be loaded? Answer Observing what Elliott said about class files, you can create (in recent versions of jar) the manifest implicitly with That

What annotation targets are applicable to Java records?

I have an annotation used for methods or fields defined like this: I wanted to prevent users from using this on a record since it wouldn’t make sense for this annotation to be used in that context. It seems doing this should not compile since I don’t specify ElementType.PARAMETER as a valid @Target. The following compiles fine though: But this

How to use @ConfigurationProperties with Records?

Java 16 introduced Records, which help to reduce boilerplate code when writing classes that carry immutable data. When I try to use a Record as @ConfigurationProperties bean as follows I get the following error message: How can I use Records as @ConfigurationProperties? Answer Answering my own question. The above error raises from Spring Boot not being able to construct the