So I guess it's an issue with NetBeans then a) using such an old version of maven b) not handle compiler version and minium required source/target correctly. Guess I just set it to 8, as that's the oldest jdk/vm I still have lay around, and don't bother anymore about it.
Thanks for your replies and time anyway.

Matt

Am 2020-02-17 13:03, schrieb Thorsten Heit:
Hi,

Scanning for projects...

(...)

-------------------------------------------------------------
COMPILATION ERROR :
-------------------------------------------------------------
Source option 5 is no longer supported. Use 6 or later.
Target option 1.5 is no longer supported. Use 1.6 or later.
2 errors
-------------------------------------------------------------

You obviously use an older version of maven-compiler-plugin that still
defaults to Java 5. In that case this error is expectable as Java 11
doesn't support compiling for Java 5 anymore.
The actual version 3.8.1 of m-compiler-p (see [1]) defaults to Java 6 as source and target for the compiler. I suggest you upgrade your pom.xml to
that version.

Anyway, I recommend you pin the version of each used plugin in your
pom.xml. Otherwise you may get different results if you upgrade Maven, the
JVM, use another OS and so on.



[1] https://maven.apache.org/plugins/maven-compiler-plugin/


Regards

Thorsten

Am 2020-02-17 13:01, schrieb Thomas Broyer:
You seem to mistake the version of the JDK you're using with the version of the Java language that your source files are written in and the JRE they
depend on (in terms of available API).
You can very well compile Java 8 sources with a JDK 11 or 13.
If you share your project between machines where you don't control the JDK,
then you'll want to make sure you never use something in your code that
won't be available in another machine, so you'll actually *want* to set a
source value (for example, you work on a machine with JDK 11 and start
using Optional#isEmpty; then switch to a machine with JDK 8, your code
won't compile)

So:

- set a source/target value to the minimum version of the JDK you want
   to support (if you have machines with JDK 8, then use source=8)
   - optional but recommended: use 'release' rather than 'source' (if
you'll only ever have JDK 9+, then just use 'release'; if you'll have JDK 8, then you'll need to setup a profile to only use 'release' on JDK 9+, and use 'source' otherwise); this will make sure that not only you won't ever use language constructs from newer Java versions (e.g. private methods in interfaces) but will also validate that you won't attempt to use an API that's not available in that version (as in the Optional#isEmpty example
   above)


On Mon, Feb 17, 2020 at 12:46 PM <[email protected]> wrote:

Sorry for the late reply, but I did some testing to make sure it wasn't
me made a stupid mistake.
So, when I clone my current repo and execute an "mvn compile" or "mvn
package" on it without messing around with the pom either all works fine
or I get a failure because the set version is higher than what'S
available on the current system. If I manual change the version to match
what the system has installed all works fine again (terminal and
Netbeans).
But when I remove the source and target from the pom I get this error
(same when using a terminal as when using Netbeans):

cd C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat;
"JAVA_HOME=C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.4.11-hotspot" cmd
/c "\"\"C:\\Program
Files\\NetBeans-11.2\\netbeans\\java\\maven\\bin\\mvn.cmd\"
-Dmaven.ext.class.path=\"C:\\Program
Files\\NetBeans-11.2\\netbeans\\java\\maven-nblib\\netbeans-eventspy.jar\"
-Dfile.encoding=UTF-8 install\""
Scanning for projects...

------------------------------------------------------------------------
Building YouTubeLiveChat 1.0
------------------------------------------------------------------------

--- maven-resources-plugin:2.6:resources (default-resources) @
YouTubeLiveChat ---
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory

C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\src\main\resources

--- maven-compiler-plugin:3.1:compile (default-compile) @
YouTubeLiveChat ---
Changes detected - recompiling the module!
Compiling 4 source files to

C:\Users\Administrator\Documents\NetBeansProjects\YouTubeLiveChat\target\classes
-------------------------------------------------------------
COMPILATION ERROR :
-------------------------------------------------------------
Source option 5 is no longer supported. Use 6 or later.
Target option 1.5 is no longer supported. Use 1.6 or later.
2 errors
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.995 s
Finished at: 2020-02-17T12:28:58+01:00
Final Memory: 10M/40M
------------------------------------------------------------------------
Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
(default-compile) on project YouTubeLiveChat: Compilation failure:
Compilation failure:
Source option 5 is no longer supported. Use 6 or later.
Target option 1.5 is no longer supported. Use 1.6 or later.
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e
switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please
read the following articles:
[Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

From what I was able to find this is because the hardcoded default value
wich is used when no other setting is found in pom in the compiler
plugin is version 5. As the error message says, this is no longer
supported and 6 or higher should be used. I didn'T filed a bug report
cause it's possible that there're version mismatches wich may cause this
- I'm not sure about that.
So, as I don't want to set a fixed value (maybe would be 8 if I have to)
I would rather prefer to disable this settings at all and just let it
compile with what ever version the system has a JDK of. Or, if it's not
possible to complete throw it out is there at least a way to not just
set a specific version but rather only a minimum? So, that a system wich
has only J8 can use this, but other system with 9, 11, 13 won'T be
enforced to compile v8 but with their own version?

As I also mentioned else where: I thought IDEs and all their build stuff
is supposed to make developing easier - but I had so many issues I
encountered since I started to use it a few days ago I really though of
go back to basic editor and terminal - wich seems easier (side-note
about dependency management: yes, sure, it's nice to have a build system
handle it for you, but as I'm used to gather libs and dependencies
myself, and many often come in bundles, and manage different and
matching versions by myself, I got a rather big lib collection used by
just point my system wide classpath to the lib directory).

So, any thoughts about how to solve that issue? I'm honestly kind of
lost, not just using Netbeans as a gui wrapper (as one of its devs
called it on their list) but also get my head around maven as the build
environment).

Thanks for any help in advance,

Matt

Am 2020-02-17 05:24, schrieb Bernd Eckenfels:
> Can you show the actual error message and give a concrete project?
> Normally Maven works with not specifying target/source as long as your
> JDK is recent enough. (But it's not ways a good idea, it's better to
> specify the properties (IDEs normally read them)
>
>
> --
> http://bernd.eckenfels.net
> ________________________________
> Von: [email protected] <[email protected]>
> Gesendet: Monday, February 17, 2020 4:27:16 AM
> An: [email protected] <[email protected]>
> Betreff: build maven project without setting compiler source and target
>
> So as I just got new into using Netbeans someone on its list explained
> me, that it's just a gui wrapper around maven and it's adviced to get
> the basics of maven to correctly use netbeans.
> Ok, so as I just used a simple editor and a terminal it didn't mattered
> wich version I compiled with or for in the past as I ran the class with
> the same vm I compiled them with. So, the I thought I could just ommit
> the setting - but maven just fails with an error that no source/target
> version was specified. So I had them re-add by re-apply the project
> settings.
> Is there a way I could tell the compiler plugin just to ignore the
> version but also to ignore if it's missing and just compile it with
> whatever version I ran maven with?
> It's basically: I use different systems all with different jdk
> installed
> - so when just clone the most recent version from github I always have
> to set the correct version manual as netbeans doesn't seem to be handle
> that by itself - and I could find an option to just get rid of it at
> all.
>
> Thanks in advance,
>
> Matt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to