Compile java and generate . jar

Asked

Viewed 282 times

0

I have a Maven project already well structured. I want to create the . jar to run the application.

Inside the project, at the prompt, I did:

mvn clean install package

Returns the error:

C: exampleSpring portal-de-inscription portal-api>mvn package

[INFO] Scanning for Projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Portal Api 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-Resources) @portal-api --- [INFO] Using 'UTF-8' encoding to copy Filtered Resources. [INFO] Copying 1 Resource [INFO] Copying 1 Resource [INFO] [INFO] --- Maven-Compiler-plugin:3.1:Compile (default-Compile) @portal-api --- [INFO] Changes Detected - recompiling the module! [INFO] Compiling 65 source files to C: exampleSpring portal-de-registration portal- api target classes [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 9.585 s [INFO] Finished at: 2015-09-03T10:39:59-03:00 [INFO] Final Memory: 10M/25M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.Maven.plugins:Maven-Compiler-plugin:3. 1:Compile (default-Compile) on project portal-api: Fatal error compiling: invali d target release: 1.8 -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e Swit ch. [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 rea d the following Articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE xception

C: exampleSpring portal-de-registration portal-api>

  • It looks like an error with the Java version, or JAVA_HOME might not be set for the current session. Try before running the above command, check the Java version. If everything is OK, inside the POM check the target version of the project, in the Maven-build-plugin. If not, post your POM.

  • @Celso Marigo Jr The measured line could not be found. I found the following: <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <start-class>com.dendetech.application.Application</start-class> <java.version>1.8</java.version> </properties> <build> The version I use is 7. Here’s how 8. This project was cloned from gitbucket. I’ll change the version and post anything.

  • It looks like you have configured in pom to compile in version 8 and you do not have version 8 of Java. Put your pom.xml there please. Take advantage of and run java -version on the terminal as well.

  • @Fabio H. Gonzales Barbosa .

  • <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupid>com.dendetech</groupid> <artifactId>portal-api</artifactId> <version>0.0.1-SNAPSHOT</version> <name>Portal Api</name> <Description>Portal Api</Description> <Parent> <groupid>org.springframework.boot</groupid> <artifactId>spring-boot-Starter-Parent</artifactId> <version>1.2.5.RELEASE</version> </Parent>

  • <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactId>spring-boot-Starter-data-jpa</artifactId> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactId>spring-boot-Starter-data-Rest</artifactId> </dependency> <dependency> <groupid>mysql</groupid> <artifactId>mysql-Connector-java</artifactId> </dependency> <dependency> <groupid>org.Hibernate</groupid> <artifactId>Hibernate-entitymanager</artifactId> <version>4.3.10.Final</version> </dependency>

  • <dependency> <groupid>org.springframework.security</groupid> <artifactId>spring-security-web</artifactId> <version>4.0.2.RELEASE</version> </dependency> </dependencies>

  • <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <start-class>com.dendetech.application.Application</start-class> <java.version>1.8</java.version>

  • <build> <pluginManagement> <plugins> <plugin> <groupid>org.springframework.boot</groupid> <artifactId>spring-boot-Maven-plugin</artifactId> <version>1.2.5.RELEASE</version> </plugin> </plugins> </pluginManagement> <plugins> <plugin> <groupid>org.springframework.boot</groupid> <artifactId>spring-boot-Maven-plugin</artifactId> <version>1.2.5.RELEASE</version> </plugin> </plugins> </build> </project>

  • Ba version of java here is 7. I can change in this file the version, or going in the property of the project and changing to the correct version and in the build recognize java?

  • Andre in your pom. is specified to compile your project with Java 8, and your Java is 7. I advise you to do the following, if you do not have any code that compiles only in Java 8 exchange in your pom the <java.version> to 1.7 or change your JAVA_HOME to point to a Java 8. If you go in the project property and switch to Java 7 for example, when you build the project it will change to 8 again as your pom.xml.

  • If you solve your problem I put an answer below ;)

Show 7 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.