DeepN
DeepN

Reputation: 344

JAVA supports platform "Dependent" concept?

I found this following log in my console while doing "MAVEN INSTALL" on my project,

[INFO] Search took 70ms
[INFO] Theme "VAADIN\themes\mytheme" updated
[INFO] 
[INFO] --- vaadin-maven-plugin:7.5.10:compile-theme (default) @ MyUI ---
[INFO] Updating theme VAADIN\themes\mytheme
[INFO] Theme "VAADIN\themes\mytheme" compiled
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ MyUI ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
          resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- vaadin-maven-plugin:7.5.10:resources (default) @ MyUI ---
[INFO] auto discovered modules [com.ui.AppWidgetset]
[INFO] 3 source files from GWT module com.ui.AppWidgetset

What is the “Platform dependent” Concept they are talking about here? JAVA supports the concept of Platform Independency due to JVM , so which “feature” of JAVA(I am calling this a feature) makes it print this line in the Console?

This means all my files are encrypted (Through SEE), if I put my WAR in non-encrypted machine(if key is different) then application may not be run?

JAVA should not have allowed this "feature".

Please note: I maybe thinking this in a totally incorrect manner, or I am missing something right in front of my eyes. Apologies, but still wanted to clear it.

Upvotes: 2

Views: 1220

Answers (3)

Hash
Hash

Reputation: 4715

This is about the character encoding. The mentioned Cp1252 is a Windows "specific" character set. (Source: https://en.wikipedia.org/wiki/Windows-1252) If you would like to remove your dependency on this particular character set save all of the resources as UTF-8 encoded files. This will eliminate the warning and lead You to a more portable version of your project. There is a way to force mvn to convert those files (https://maven.apache.org/general.html#encoding-warning) but it could create some errors. Try to keep all of your resources in UTF-8.

Upvotes: 3

Andreas Krueger
Andreas Krueger

Reputation: 51

Your question relates more to Maven as build system (Software) than Java itself. The Maven build happens in several steps/ phases: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

In one step the resources, i.e. html, XML, csv and other text files are copied, by the Maven resources plugin: https://maven.apache.org/plugins/maven-resources-plugin/examples/encoding.html

[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
          resources, i.e. build is platform dependent!

Filtered here means that the plugin can make a text replacement for your Maven properties defined in the POM or predefined Maven properties as ${project.version}. Thus, you can have an automatic Version displayed in one of your .html files.

The Maven Resources Plugin can be configured to work with specific character Encodings / file encodings: https://maven.apache.org/plugins/maven-resources-plugin/examples/encoding.html

When you don't explicitly state one, Maven takes the platform's Default character Encoding, which is in your case on a Windows System cp-1252, and the build becomes platform dependent.

Upvotes: 1

dasrohith
dasrohith

Reputation: 533

At the time of Building the project Maven plugins may copy resources. That is why it is showing this warning. If you want to make it independent you can add the following to the pom file

<project>
  ...
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  ...
</project>

This is actually a frequently asked question in maven.

This or a similar warning is emitted by a plugin that processes plain text files but has not been configured to use a specific file encoding. So eliminating the warning is simply a matter of finding out which plugin emits it and how to configure the file encoding for it. This is as easy as adding the following property to your POM (or one of its parent POMs):

Upvotes: 5

Related Questions