When debugging I get an warning message on exception saying 'variable info not available - compiled without -g' - how do I set to compile with -g in netbeans?
thanks
As far as I know your own code is compiled with debug information. The Java runtime library, however, isn't.
Please double check that the location you see this message, is in your own code and not the runtime library.
In my Nb 7.4 there is a "generate Debuging info" flag on
project propertyes -> Build -> compile ;
but if you, like me, are using maven, you have to check in pom.xml too
let me show an example:
you can ave a production profile and in that profile you can have the maven compiler plugin with debug setting to false
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.6</source>
<target>1.6</target>
<showWarnings>true</showWarnings>
<debug>false</debug>
<optimize>true</optimize>
</configuration>
</plugin>
</plugins>
</build>
...
see the false setting
if you have a similar setting on your pom.xml local variable on debug are not show.
Related
I got this error while running a junit-test in my application. Which I later found out because of declared field size
java.lang.IllegalArgumentException: Comparison method violates its general contract!
at java.util.TimSort.mergeHi(TimSort.java:899)
at java.util.TimSort.mergeAt(TimSort.java:516)
at java.util.TimSort.mergeCollapse(TimSort.java:441)
...
org.mockito.internal.configuration.injection.PropertyAndSetterInjection.orderedInstanceFieldsFrom(PropertyAndSetterInjection.java:125)
I found that probable solution would be adding this flag.
-Djava.util.Arrays.useLegacyMergeSort=true in VM args. But I wanted to add in pom.xml
I referred to this how to add VM args using pom xml but it refers mostly for -X flags, what would be an appropriate placement in here?
I updated the pom.xml with the surefire plugin and used argLine parameter as suggested here
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Djava.util.Arrays.useLegacyMergeSort=true</argLine>
</configuration>
</plugin>
Trere are 2 ways to configure [System Properties in surefire plugin] (https://maven.apache.org/surefire/maven-surefire-plugin/examples/system-properties.html)
Option 1: systemPropertyVariables
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<systemPropertyVariables>
<java.util.Arrays.useLegacyMergeSort>true</java.util.Arrays.useLegacyMergeSort>
</systemPropertyVariables>
</configuration>
</plugin>
Option 2: argLine
Some system properties must be set on the command line of the forked VM, and cannot be set after the VM has been started. These properties must be added to the argLine parameter of the Surefire plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-Djava.util.Arrays.useLegacyMergeSort=true</argLine>
</configuration>
</plugin>
Upgrade your dependencies
On the other hand, I really think that the right solution is to upgrade Mockito to 2.1 or later
2.1 was released in October, 2016, and contains the fix to your issue: Make PropertyAndSetterInjection field sorting consistent #176
Can somebody tell me what are all the places where I have to change the java version, because I have changed it in more than 5 places so far (I don't even remember all of them) and it is still saying "diamond operator is not supported in -source 1.5". The most stupid ide ever..
Project -> Project SDK
Project -> Project language level
Modules -> Language level
Project bytecode version
Target bytecode version
If you use Maven in IntelliJ IDEA to build your project you have to set Java version as parameters source and target in configuration for maven-compiler-plugin:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Default version for this is 1.5 and IDE use it to check source code compatibility.
I am aware that similar questions has been asked in the past, but I couldn't found my answer in it.
I am using Eclipse Luna and upgraded to java 8 (build 0.25).
The JAVA_HOME points to java 8 and also it's part of the Windows Classpath.
After the upgrade, maven compile shows some Ambiguous method calls that didn't show up in java 7.
The problem is that these errors aren't shown in Eclipse and I can't find why.
I removed all jre's in eclipse and removed/added the java 8 jdk, but still no luck.
Also Eclipse is using the java 8 environment for compiler errors/warnings.
With maven I use the "plexus-compiler-javac" compiler, snapshot 2-4. I also tried without the plexus compiler and with version 2.0, but no luck.
Any idea what this could be?
My Pom snippet:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<!--version>2.0</version-->
<version>2.4-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<verbose>true</verbose>
<source>1.8</source>
<target>1.8</target>
<fork>false</fork>
<encoding>utf-8</encoding>
<meminitial>256m</meminitial>
<maxmem>1024m</maxmem>
</configuration>
</plugin>
Try telling maven to use java 8 source level by adding/changing configuration of your compile plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
i face this issue with tools.jar not found, so download the latest tools.jar & copy to D:\Java\jdk1.8.0_25..\lib\tools.jar, thanks.
I have this problem when creating a maven project. I can't change the JRE library from J2SE-1.5 to Java-S.E 1.6 or 1.7 without errors. (and even with the J2SE-1.5, I have a warning)
I know that it's set by default, so I changed the maven compiler plugin.pom file but I still get the same error.
Here is what i modified in my pom.xml file:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
Just changing the java version in your pom.xml is not good enough. You need to have the environment variable JAVA_HOME set to the version you intend to use. Maven uses this variable to build your project, so JAVA_HOME and the compiler plugin version must match.
I'm using some JSR166 classes with Java 1.6, some of which are under java.util.concurrent. I am on OSX, though I expect this to ultimately run on Linux.
If I set this environment variable I can run my project:
export MAVEN_OPTS=-Xbootclasspath/p:/Users/me/.m2/repository/org/codehaus/jsr166-mirror/jsr166/1.7.0/jsr166-1.7.0.jar
I tried following the instructions here and putting the setting in my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<version>3.0</version>
<compilerArguments>
<verbose/>
<bootclasspath>/Users/me/.m2/repository/org/codehaus/jsr166-mirror/jsr166/1.7.0/jsr166-1.7.0.jar</bootclasspath>
</compilerArguments>
</configuration>
</plugin>
Unfortunately this gave an error about not being able to find java.lang. If I add a reference to classes.jar (apparently OSX's version of rt.jar) in the bootclasspath I can fix that error, but that just puts me back where I started:
java.lang.SecurityException: Prohibited package name: java.util.concurrent
How should I set up maven to use this argument correctly?
You should check security manager. Unfortunately, I don't know specific on OSX. By default, the JVMuses security policies defined in the java.security and java.policy files located under the JAVA_HOME/jre/lib/security folder. Check also -Djava.security.manager and –Djava.security.policy option for your JVM.
Shouldn't you use extdir for this, instead of bootclasspath?
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<compilerArgs>
<arg>-verbose</arg>
<arg>-extdir /Users/me/.m2/repository/org/codehaus/jsr166-mirror/jsr166/1.7.0/</arg>
</compilerArgs>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
From http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html