Comments (11)
This problem is triggered by the following maven config:
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<scalaCompatVersion>${scala.binary.version}</scalaCompatVersion>
<recompileMode>incremental</recompileMode>
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-g:vars</arg>
<arg>-encoding</arg>
<arg>UTF-8</arg>
<arg>-Xlint</arg>
</args>
<javacArgs>
<!-- <javacArg>-source</javacArg>-->
<!-- <javacArg>${java.version}</javacArg>-->
<!-- <javacArg>-target</javacArg>-->
<!-- <javacArg>${java.version}</javacArg>-->
</javacArgs>
</configuration>
from scala-maven-plugin.
Please provide a complete standalone reproducer like described in here, otherwise there's no way to help.
Also, make sure your linux user as execute permission on Java.
from scala-maven-plugin.
Happened to me as well. The situation occurs when the environment variable JAVA_HOME
does not exist, and maven uses the java executable from PATH
. You can avoid it by setting JAVA_HOME
.
This happens because the path detection for java
in JavaLocator.findExecutableFromToolchain
returns the JRE Path instead of JDK. This is wrong in my oppinion, it should be possible to detect the JDK if it is PATH
.
In my tests the argument toolchain
of JavaLocator.findExecutableFromToolchain
was always null. Maybe that's the problem.
from scala-maven-plugin.
Can't say what happens exactly on your setup.
What I can say for sure is that scalac works with a simple JRE but can only compile Scala code.
A JDK is required in order to compile Java code, which is what happens when you have a mixed project.
I'd say the issue if with your setup and you have to provide a proper JDK and note a simple JRE if you want to compile Java code too.
I'm closing for now. I'll reopen if someone finds an issue with the Java resolution and provides a reproducer.
from scala-maven-plugin.
@slandelle yes, in my case I have Java sources as well. And I provide a JDK, not a JRE, but not in the environment variable JAVA_HOME
, but in the PATH
. In my oppionion it should work in this case as well.
from scala-maven-plugin.
but in the PATH. In my oppionion it should work in this case as well.
Why? Why would it have precedence over the JVM that was used to launch maven?
from scala-maven-plugin.
Because the JVM that was used to launch Maven is a JDK. It's the java executable from a JDK.
I will gladly provide a reproducer, if you tell me what your expectations are. A full project where the problem is repoduced?
from scala-maven-plugin.
A full project where the problem is repoduced?
Yes
from scala-maven-plugin.
Here you go. To reproduce the error:
- make sure a java JDK is in the Path, in my case it's
c:\Program Files\Eclipse Adoptium\jdk-8.0.312.7-hotspot\bin\
- make sure
JAVA_HOME
is not defined - run
mvn clean compile
=> following error occurs:
[INFO] compiling 1 Scala source and 1 Java source to D:\scala-test-prj\target\classes ...
[WARNING] javac exited with exit code -1
[ERROR] ## Exception when compiling 2 sources to D:\scala-test-prj\target\classes
java.io.IOException: Cannot run program "C:\Program Files\Eclipse Adoptium\jdk-8.0.312.7-hotspot\jre\bin\javac" (in directory "D:\scala-test-prj"): CreateProcess error=2, The system cannot find the file specified
java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:85)
scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:119)
scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$anonfun$runBuffered$1(ProcessBuilderImpl.scala:205)
scala.runtime.java8.JFunction0$mcI$sp.apply(JFunction0$mcI$sp.scala:17)
sbt.internal.inc.javac.JavacLogger.buffer(JavacProcessLogger.scala:49)
scala.sys.process.ProcessBuilderImpl$AbstractBuilder.runBuffered(ProcessBuilderImpl.scala:205)
scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang(ProcessBuilderImpl.scala:146)
sbt.internal.inc.javac.ForkedJava$.$anonfun$launch$3(ForkedJava.scala:55)
sbt.internal.inc.javac.ForkedJava$.$anonfun$launch$3$adapted(ForkedJava.scala:48)
sbt.internal.inc.javac.ForkedJava$.$anonfun$withArgumentFile$1(ForkedJava.scala:77)
sbt.io.IO$.withTemporaryDirectory(IO.scala:490)
sbt.io.IO$.withTemporaryDirectory(IO.scala:500)
sbt.internal.inc.javac.ForkedJava$.withArgumentFile(ForkedJava.scala:74)
sbt.internal.inc.javac.ForkedJava$.launch(ForkedJava.scala:48)
sbt.internal.inc.javac.ForkedJavaCompiler.run(ForkedJava.scala:103)
sbt.internal.inc.javac.AnalyzingJavaCompiler.$anonfun$compile$12(AnalyzingJavaCompiler.scala:172)
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
sbt.internal.inc.javac.AnalyzingJavaCompiler.timed(AnalyzingJavaCompiler.scala:262)
sbt.internal.inc.javac.AnalyzingJavaCompiler.compile(AnalyzingJavaCompiler.scala:161)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compileJava$2(MixedAnalyzingCompiler.scala:103)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compileJava$2$adapted(MixedAnalyzingCompiler.scala:91)
sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compileJava$1(MixedAnalyzingCompiler.scala:91)
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
sbt.internal.inc.MixedAnalyzingCompiler.compileJava(MixedAnalyzingCompiler.scala:61)
sbt.internal.inc.MixedAnalyzingCompiler.compileJava0$1(MixedAnalyzingCompiler.scala:197)
sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:177)
sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:175)
sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:461)
sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:416)
sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:503)
sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:403)
sbt.internal.inc.Incremental$.apply(Incremental.scala:169)
sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
sbt_inc.SbtIncrementalCompiler.compile(SbtIncrementalCompiler.java:186)
scala_maven.ScalaCompilerSupport.incrementalCompile(ScalaCompilerSupport.java:364)
scala_maven.ScalaCompilerSupport.compile(ScalaCompilerSupport.java:122)
scala_maven.ScalaCompilerSupport.doExecute(ScalaCompilerSupport.java:89)
scala_maven.ScalaMojoSupport.execute(ScalaMojoSupport.java:310)
scala_maven.ScalaCompileMojo.execute(ScalaCompileMojo.java:108)
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.779 s
[INFO] Finished at: 2022-07-11T15:14:37+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:4.6.3:compile (default-compile) on project scala-test-prj: wrap: java.io.IOException: Cannot run program "C:\Program Files\Eclipse Adoptium\jdk-8.0.312.7-hotspot\jre\bin\javac" (in directory "D:\scala-test-prj"): CreateProcess error=2, The system cannot find the file specified -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
from scala-maven-plugin.
This is a Windows specific error and I don't have a Windows machine.
@roti Could you please provide me with the full content layout of your c:\Program Files\Eclipse Adoptium\jdk-8.0.312.7-hotspot
?
from scala-maven-plugin.
@slandelle It's the JDK from the Temurin Project: https://adoptium.net/temurin/releases/?version=8
I listed the files and folders in the attached file.
jdk_files.txt
from scala-maven-plugin.
Related Issues (20)
- Build error on `sun.*` APIs when `-release` Java version is lower than the execution Java version HOT 2
- Need to update to handle the movement of doxia to apache HOT 6
- Preview compiler features in a mixed Java/Scala Project HOT 12
- Unused 'scalaCompatVersion' flag ? HOT 10
- scala-maven-plugin version for scala-library 2.12.15? HOT 2
- Race condition in sbt-compiler-bridge jar when running multimodule project with -T HOT 3
- Maven 3.9.4 Validation Warnings HOT 2
- Getting object scala in compiler mirror not found issue while running the application using jar HOT 3
- Trouble with installing the Maven plugin in IntelliJ HOT 3
- Unable to download 4.9.1 through the Maven repository HOT 3
- Release a new version with new zinc? HOT 2
- Does this plugin support multi version of Scala? HOT 1
- Goals Page returns 404 HOT 5
- Error when compile with 3.4.2 HOT 27
- An API incompatibility was encountered while executing net.alchim31.maven:scala-maven-plugin:4.0.0
- Failed to execute goal net.alchim31.maven:scala-maven-plugin:4.8.0 HOT 1
- Plugin is a Maven 2.x plugin and mixes multiple Maven versions HOT 1
- Warning "Plugin execution not covered by lifecycle configuration: ..." HOT 3
- Does new Scala 3 Syntax work with this plugin? HOT 2
- Spark build getting failed [3.5.0, 3.5.1] HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scala-maven-plugin.