I have this problem that i can't understand how to solve. i have imported a maps forge project in eclipse using maven, but if try to load the project on device, i get this error.
But i know that that class is in the project. How can i solve this problem?
I am working with the Mapsforge rescue 4.0 library.
I have used the same method to import Mapsforge 0.31 and everything works fine.
02-25 16:46:03.202: E/AndroidRuntime(6370): java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory
This is the pom.xml of the app.
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.mapsforge
mapsforge
0.4.0-SNAPSHOT
../../../pom.xml
<artifactId>Samples</artifactId>
<packaging>apk</packaging>
<properties>
<rootDirectory>../../../</rootDirectory>
<targetJdk>1.6</targetJdk>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<dex>
<jvmArguments>
<jvmArgument>-Xmx512M</jvmArgument>
</jvmArguments>
</dex>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<useProjectReferences>false</useProjectReferences>
<buildOutputDirectory>bin/classes</buildOutputDirectory>
<additionalBuildcommands>
<buildcommand>com.android.ide.eclipse.adt.ResourceManagerBuilder</buildcommand>
<buildcommand>com.android.ide.eclipse.adt.PreCompilerBuilder</buildcommand>
<buildcommand>com.android.ide.eclipse.adt.ApkBuilder</buildcommand>
<buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
<projectnature>com.android.ide.eclipse.adt.AndroidNature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>com.android.ide.eclipse.adt.ANDROID_FRAMEWORK</classpathContainer>
<classpathContainer>com.android.ide.eclipse.adt.LIBRARIES</classpathContainer>
<classpathContainer>com.android.ide.eclipse.adt.DEPENDENCIES</classpathContainer>
</classpathContainers>
<excludes>
<exclude>com.google.android:android</exclude>
<exclude>org.apache.httpcomponents:httpclient</exclude>
<exclude>org.apache.httpcomponents:httpcore</exclude>
<exclude>commons-codec:commons-codec</exclude>
<exclude>commons-logging:commons-logging</exclude>
<exclude>org.json:json</exclude>
<exclude>org.khronos:opengl-api</exclude>
<exclude>xerces:xmlParserAPIs</exclude>
<exclude>xpp3:xpp3</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mapsforge</groupId>
<artifactId>mapsforge-map-android</artifactId>
<type>apklib</type>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.4.2_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
<version>5.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
</dependencies>
The solution is as follows:
Download those 5 files:
mapsforge-core
mapsforge-map
mapsforge-map-reader
mapsforge-map-android
svg-android
Put those libraries (jar files) in your project folder libs
Than go to Project->clean
You don't need to install Maven or other plugins. Including the libraries through Java Build Path -> Libraries -> Add External JARs won't work. You need to put it in the libs folder.
If it still doesn't work, make sure you update your android tools and try again.
Good luck :)
Related
I am making a JavaFX project (for the GUI) on Maven and for the moment I want to convert a StringBuffer object to JSON.
I tried to add the dependency org.json from Maven but there is a problem in pom.xml file
Missing Artifact org.json:json:bundle:20220924
I tried adding an older version of org.json dependency, it had the same issue
I tried a different dependency, everything was ok in the pom.xml file but I could not import it into my project (any dependency).
All dependencies return this error: The type org.json.JSONArray is not accessible
Lastly, I tried to download the json-java.jar from github and add it into a libs folder on the base project directory and added it in the pom file as a dependency but it could not be resolved either.
My pom.xml file:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>books</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
<type>bundle</type>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>13</version>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>sample</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/json-20220924.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.6</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.example.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
In the end I downloaded Maven again and extracted it into a folder and changed my environment variables on path. Maven is successfully installed on version 3.8.7
Thank you in advance for any help!
UPDATE
I should mention that I tried it on a new java project (without maven) and it works fine, by importing the .jar file from git-hub repository
This question already has answers here:
IntelliJ can't recognize JavaFX 11 with OpenJDK 11
(7 answers)
Closed 1 year ago.
I use IntelliJ with open-sdk 11.0.12.
I have projekt based on maven.
I started with empty project and added some dependencies.
I'm in the middle of creating JavaFX application.
My pom.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
4.0.0
<groupId>org.example</groupId>
<artifactId>kalkulator</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<id>run</id>
<configuration>
<mainClass>project.Main</mainClass>
</configuration>
</execution>
<execution>
<id>debug</id>
<configuration>
<mainClass>project.Main</mainClass>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8000</option>
</options>
</configuration>
</execution>
</executions>
<configuration>
<mainClass>${project.mainClass}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
<scope>test</scope>
</dependency>
<!-- JavaFX -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>5.0.0.Final</version>
</dependency>
</dependencies>
<properties>
<project.mainClass>me.noname.calculator.Calculator</project.mainClass>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
When I run it with maven it works fine.
I have set goal: clean javafx:run.
I would like to run this project local in intellij, but the error shows:
Error: JavaFX runtime components are missing, and are required to run this application
I tried to make module file, but then it shows that the javafx.application.Application is missing.
Which is strange because I have it from dependency.
What should I do so I can use local debugger on this code?
I resolved my problem by creating a new JavaFX project in IntelliJ.
I still depend on maven. That was the fastest way. But I still would like to know why it was not working from the empty maven project and what was the difference.
I keep getting this error while trying to deploy an application to AWS:
An internal error occurred during: "Updating AWS Elastic Beanstalk environment:
SampleWebApplication".
javax/xml/bind/JAXBException
Here is what I do:
I create new Maven project based on maven-archetype-webapp 1.0
I configure the pom.xml file with dependencies (full file below)
I type in whatever to index.jsp (it's supposed to be super easy application)
I run it on tomcat7:run, it works like a charm on http://localhost:8080/
I create AWS Server
I select the project, I choose Amazon Web Services Tool --> Deploy to AWS Elastik Beanstalk, choose the added server and I keep getting this message:
I am not able to find any information about this error in the internet. The only thing that I have found is that it is connected to Java version, but I am running Java 1.8 (as was suggested in one post that I found).
Can anyone please help me? I am following this instruction for deployment of the application.
I'm super new to AWS so I don't even know where to start!
index.jsp
<html>
<body>
<h2>Hello There!</h2>
</body>
</html>
pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dominikazb</groupId>
<artifactId>SampleWebApplication</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>SampleWebApplication Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<tomcat.version>7.0.50</tomcat.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<build>
<finalName>SampleWebApplication</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<wtpversion>2.0</wtpversion>
<wtpContextName>todo</wtpContextName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<verbose>true</verbose>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webappDirectory>${project.build.directory}/${project.artifactId}
</webappDirectory>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
Project structure
Please, please, please help!
Finally, I find an answer to this problem in the website:
https://github.com/aws/aws-toolkit-eclipse/issues/123
The examples there were in Unix. Mine is in Window 7. What I did base on the website suggestion is:
Find where is the file jaxb-api-2.2.5.jar located. I am not sure if version 2.2.5 is a must. Suggest try whatever you have.
Mine is located in
C:\Users\myUserName\.m2\repository\javax\xml\bind\jaxb-api\2.2.5.
Exit the Eclipse IDE.
Open PowerShell in Admin mode.
cd to your user directory (my case C:\Users\myUserName) and execute the following command to open the Eclipse IDE with a -dev option which points to the jaxb-api-2.2.5.jar.
C:\Users\myUserName\eclipse\jee-2020-09\eclipse\eclipse -dev $(ls ~/.m2/repository/javax/xml/bind/jaxb-api/*/*[0-9].jar | Select-Object -Last 1)
Certainly, the location of your eclipse.exe can be different.
Happy coding!
I am trying to create a program that will use the sikulix libraries. So I copy pasted the dependencies from https://mvnrepository.com/artifact/com.sikulix/sikulixapi/1.1.2. Then I ran mvn install to install the libraries and I got this error
[ERROR] Failed to execute goal on project auto-fish: Could not resolve dependencies for project com.bine:auto-fish:jar:1.0: Could not find artifact com.github.vidstige:jadb:jar:-v1.0-g94ebf38-23 in central (https://repo.maven.apache.org/maven2)
After doing some research I realized I may need to add a repositories tag with the sikulixapi repo. That gave me this error.
[ERROR] Failed to execute goal on project auto-fish: Could not resolve dependencies for project com.bine:auto-fish:jar:1.0: Could not find artifact com.github.vidstige:jadb:jar:-v1.0-g94ebf38-23 in Sikulix Repo (https://mvnrepository.com/artifact/com.sikulix/sikulixapi)
At this point I am unsure as to what I should do. This is my first every Maven project.
`
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.bine</groupId>
<artifactId>auto-fish</artifactId>
<version>1.0</version>
<name>auto-fish</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>Sikulix Repo</id>
<url>https://mvnrepository.com/artifact/com.sikulix/sikulixapi</url>
</repository>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sikulix/sikulixapi -->
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
`
The code is split up but note that they are all in the pom file for my maven project. Also the first 5 lines aren't not showing up for some reason but I feel like they are not important. And i'm using Vs code for all this.
And if you're wondering the goal of this is to create something that will play some dumb fishing game for me, but this is more of a test to see if I can pull it off rather than something I actually need lol.
If you look at your vidstige artifact in mvnrepository.com, you'll see it lists "Mulesoft" as the only repo that contains it. Following that link shows https://repository.mulesoft.org/nexus/content/repositories/public/ as the optional repository URL you should be adding, not the mvnrepository URL you added which was just a link to the mvnrepository search engine results.
So in short, this should hopefully work:
<repository>
<id>Mulesoft Repo</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
</repository>
Note I'm unfamiliar with this repository, so if it requires any kind of authentication or licensing you would want to follow up with instructions from that repo owner.
Alternatively you can skip the dependency download using exclusion.
Since i am not aware of your source code. I am just suggesting this solution
<dependency>
<exclusions>
<exclusion>
<groupId>com.github.vidstige</groupId>
<artifactId>jadb</artifactId>
</exclusion>
</exclusions>
</dependency>
Solution found from LaunchPad
I have 2 maven projects
1) My Utils Project - imports datecalc-common as a dependency, contains my custom utility classes. Note that it doesn't have a main class.
2) My Main Project - imports 'My Utils Project' as a dependency.
'My Main Project' shows the error 'Cannot find class HolidayCalculator'.
My Utils Project-pom.xml is given below.
How do I modify it so that the dependency jars are included as part of 'My Utils Project'.jar ?
<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.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<groupId>com.mycompany.mycommoncode</groupId>
<artifactId>myutilsjar</artifactId>
<version>0.0.12-SNAPSHOT</version>
<name>myutilsjar</name>
<description>Common Date Utils used by my classes</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>net.objectlab.kit</groupId>
<artifactId>datecalc-common</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>net.objectlab.kit</groupId>
<artifactId>datecalc-jdk8</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
<version>3.1.4</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<url>my maven url</url>
</snapshotRepository>
</distributionManagement>
</project>
NOTE: I DO NOT want to use 'shade' plugin. Is there any other way of doing this?
I had to solve that same issue some months ago. I wrote a small library that was to be shared between many projects and I wanted to add it to maven.
This is what I did.
For your "Utils project"
Compile it using maven-assembly-plugin:
Add this to your pom.xml:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Build the library with it's dependencies using the following command:
mvn clean compile assembly:attached
For your main project
Add this plugin to your pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${project.basedir}/src/main/resources/lib/sso-client-1.0.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>SSOClient</groupId>
<artifactId>sso-client</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
As you can see, I wrote a custom SSO Client.
This will read the jar you compiled in the previous step, and make it available as a dependency. I decided to place it in the resources folder of the main project. The version has to match the one in your "utils project".
Also add the dependency to the pom.xml:
<dependency>
<groupId>SSOClient</groupId>
<artifactId>sso-client</artifactId>
<version>1.0</version>
</dependency>
That's it! You can now reference the classes of the package in your main project.
Let me know if you need clarification.
The Apache Maven Shade Plugin provides the capability to package your artifact in a "uber-jar", that is to say a jar including all dependencies required to run the project. If needed this plugin also supports packages shading (renaming) for some of the dependencies.
More info at:
https://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html#