I'm writing assignment on coursera.org Java course. I'm using Maven and I have external jars that I have to use in this course (course requirements).
This is part of my pom.xml:
<dependency>
<groupId>org.coursera.algs4part1</groupId>
<artifactId>stdlib</artifactId>
<version>1.0</version>
</dependency>
I can't make java compiler import the external jar file. Below, following errors occur:
The import org.coursera.algs4part1.stdlib cannot be resolved
But I've successfully added the jar to maven:
What am I missing?
You need to do the following steps if you have a eclipse-maven plugin installed.
Run the command mvn eclipse:eclipse
Go to Project Properties > Build Path > Libraries tab > Add Variable... button > Configure Variables... button > New button. Enter the variable name as M2_REPO and its value/path to the Maven Repository path (Usually it's like C:\Users\<username>\.m2\repository.)
1.create a folder src\lib and paste your jar file
2.your pom.xml should be like this.
<groupId>org.coursera.algs4part1</groupId>
<artifactId>stdlib</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\lib\stdlib.jar</systemPath>
</dependency>
Hopefully this will solve your problem and for more details visit http://noexceptionfound.blogspot.in/
Related
Maybe a newbie question...
I've been working on a LWJGL project, where I use Maven to manage dependencies. In it, I want to use some parts of the libgdx library. So I figured I will first run at least a helloworld working with it before I add it to my main project.
So in my pom.xml I have this:
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-backend-lwjgl -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-backend-lwjgl</artifactId>
<version>1.9.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx-platform -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>1.9.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.badlogicgames.gdx/gdx -->
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx</artifactId>
<version>1.9.11</version>
</dependency>
The other contents of the file are the same as in a working project and are 100% working.
I tried creating a separate libgdx project before that and... it didn't work. But, I saw that the code that was supposed to run the program was:
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
new LwjglApplication(new SomeApplicationListenerFile(), config);
}
So I used that in my maven project.
When I do "run as a Java Application", the error is the following:
Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/backends/lwjgl/LwjglApplicationConfiguration
at org.boby.RayTracing.main.Main.main(Main.java:179)
And if I do a Maven Build, it tells me that "package com.badlogic.gdx.backends.lwjgl does not exist"
I looked for that package in the jars Maven downloaded in the "Maven dependencies" folder and I found it in gdx-backend-lwjgl-1.9.11.jar - right where it should be.
The package is apparently there, but Java cannot find it. How can I fix that?
Some additional information:
Windows 10, eclipse oxygen, Maven 3.6.0, JRE 1.8.0_191, JDK 8
Thank you in advance! I've been banging my head on this for hours.
Edit: I made some progress. Looks like the "test" was messing things up so I removed those statements. Now I get the following Error:
Exception in thread "main" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx64.dll' for target: Windows 10, 64-bit
at com.badlogic.gdx.utils.SharedLibraryLoader.load(SharedLibraryLoader.java:125)
at com.badlogic.gdx.utils.GdxNativesLoader.load(GdxNativesLoader.java:33)
at com.badlogic.gdx.backends.lwjgl.LwjglNativesLoader.load(LwjglNativesLoader.java:47)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:83)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.<init>(LwjglApplication.java:71)
at org.boby.RayTracing.main.Main.main(Main.java:178)
It looks like I need to include gdx-natives.jar in my dependencies, but I can't find a maven repository for it.
I downloaded gdx-natives.jar (saw it in a forum thread). In there, was a file named "gdx-64.dll". As I need "gdx64.dll", I just renamed the dll and now it runs.
You can let Maven do the work if you define the gdx-platform dep like this:
<dependency>
<groupId>com.badlogicgames.gdx</groupId>
<artifactId>gdx-platform</artifactId>
<version>1.9.11</version>
<classifier>natives-desktop</classifier>
</dependency>
This will load the natives jar including the gdx64.dll so you don't have to add any external jar to your project in the build path.
A side note is: if you use the standard Maven repo directory structure and you load assets with the Gdx.files.internal("fileName") statement you need to define a folder in the main/repository with the same name as the package you have your code in. (i.e. main/java/myPackage relates to /main/repository/myPackage). I struggled a bit with this because I don't normaly have to define a package folder int the repository dir.
I am very new to java
I downloaded an open source java project
which has this line of code
import sun.swing.SwingUtilities2;
I am getting this error
Error:(94, 38) java: cannot find symbol
symbol: variable SwingUtilities2
location: class org.apache.ctakes.gui.component.SmoothToolTip.SmoothToolTipUI
I have downloaded this jar file from here
http://www.java2s.com/Code/Jar/j/Downloadjsdgstubsjre15jar.htm
I am trying to add it to my project
through going to project structure in IntelliJ and then add library
but I get another error when i click the ok button
how to import this library in my project ?
It's like to be a maven project.
if so, why not trying to add the dependency instead of downloading the jar file manually?
try to add:
<!-- https://mvnrepository.com/artifact/com.sun/tools -->
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5.0</version>
<scope>system</scope>
</dependency>
to your pom file and then build the project again.
this way maven download it for you automatically.
We created client for web-service with security policy to call the other web-service by passing the required information like username,password and other information..Jdeveloper had given the support for security policy and their packages but to create the war and building the application we are using maven.
when we compile through maven it is giving the compilation errors.
Can any one suggest is there any plug in to add in the maven to compile the code..
Please click below link to see the image of compilation error :
Compilation errors in console when we run Maven
The Package weblogic.wsee.jws.jaxws.owsm is part of weblogic middleware and is installed on the modules folder.
You can add it to your maven repository for example Nexus as:
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>ws.api</artifactId>
<version>1.1.0.0</version>
</dependency>
The file is %MW_HOME%\modules\ws.api_1.1.0.0.jar
or, of course, if you don't want the hassle of going through adding artifacts to the repository:
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>ws.api</artifactId>
<version>1.1.0.0</version>
<scope>system</scope>
<systemPath>${mw.home}/modules/ws.api_1.1.0.0.jar</systemPath>
</dependency>
I want to build one jar that includes a child module which depends on other package of my own project.
The output one jar should include all the related class (both from jar and my own project's classes).So the child module's classes is the base classes that should be included in the output jar,and these import some classes of my own project.All the related classes in my own project should be included.
for more detail please visit How to automatically collect all related class into one jar (use maven)?
Here is what I already find:
<project>
<dependencies>
<dependency>
<scope>system</scope>
<systemPath>D:\how\to\write</systemPath>
<groupId>how.to.write</groupId>
<artifactId>how-to-write</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>java-source</type>
</dependency>
</dependencies>
</project>
The error message is : Could not find artifact how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT at specified path D:\how\to\write
the path D:\how\to\write contains my own project's classes that could support the build
Your maven dependency will look for a jar file with name how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT in D:\how\to\write directory. Since you do not have one, the build will fail.
If your own project does not use maven, then you should create a jar file and place it in D:\how\to\write location and rename it to how.to.write:how-to-write:jar:sources:0.0.1-SNAPSHOT. Then your build mvn clean install will be success.
The command for creating jar file is jar cf jar-file input-file(s).
Have a look at this page on how to create a jar file
Could you please help me to find Dependency tag for rs2xml.jar. i think it is really helpful for me. net.proteanit.sql.DbUtils
I checked the Maven Central Repository as well as the MvnRepository for the rs2xml JAR file and could not find it. A Google search for a POM corresponding to this dependency also came up empty. However, you can still manually install the JAR into your own local repository and then use it as if it were any other dependency.
mvn install:install-file -Dfile=C:\rs2xml.jar -DgroupId=net.proteanit.sql
-DartifactId=rs2xml -Dversion=1.0 -Dpackaging=jar
Replace the path C:\rs2xml.jar with the actual location on your computer where you downloaded the JAR. To use the rs2xml dependency in your project, include the following tag in your POM file:
<dependency>
<groupId>net.proteanit.sql</groupId>
<artifactId>rs2xml</artifactId>
<version>1.0</version>
</dependency>
I have to extracrt the package:
net.proteanit.sql.DbUtils
to import im my project.
It's works!
Before I tried to edit pom.xml with the sugestion :
<dependency>
<groupId>net.proteanit.sql</groupId>
<artifactId>rs2xml</artifactId>
<version>1.0</version>
But doesn't works... :(
https://github.com/wfrsilva/javaMySQL03_infoX