I am having trouble using the Jsoup library on my project - eclipse

I downloaded the latest Jsoup and moved it to my workspace in finder. I then added it to the ClassPath thing under the Project Properties. However when I try and import Jsoup classes/packages in the code, I get an error that says the element cannot be resolved. Is there any other thing I should check to ensure that the software usable?
This is for an Eclipse project that I am using to practice scraping.

I'll show you how I'm doing it and what's the result.
Adding Jsoup library to project:
Then it looks like this:
Then when I peek into my .classpath file it has a new line with jsoup path:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.8.0_161"/>
<classpathentry kind="lib" path="F:/lib/jsoup/jsoup-1.12.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
This way every import to Jsoup classes is easily recognized and missing imports are resolved without problems.

Related

Glassfish 4, Eclipse IDE 2019-03 - CustomRealm: AppservPasswordLoginModule cannot be resolved to a type

I would like to implement a Custom Realm by overriding the security classes but I'm getting an error:
AppservPasswordLoginModule cannot be resolved to a type
The import com.sun.appserv cannot be resolved
I followed the steps from this tutorial: https://computingat40s.wordpress.com/how-to-create-a-custom-realm-in-glassfish-3-1-2-2/
What I did:
I created a new java project
Added a new lib folder to my project.
Copied the security.jar(also tried with security-ee.jar) from $glassfish-installation-folder\glassfish\modules to lib folder
I added this line to my .classpath file:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/security.jar" />
<classpathentry kind="output" path="bin"/>
</classpath>
I also tried to add the jar to build path using Eclipse GUI
NOTES: I'm not using MAVEN, I also tried to clean the project as it was mentioned in other answers
After making this steps Eclipse throws me an arror when I want to extend MyCustomModule with AppservPasswordLoginModule:
enter image description here
UPDATE!
I found the JAR that must be added to JAVA build path: glassfish-ee-api.jar
I solved the problem by creating a new library where I copied all the JARS from $glassfish-installation-folder\glassfish\modules
Photo

Gradle/Eclipse issue when importing projects

Have been using Gradle with Eclipse on a multi-project development effort for over two years. During that time, every once in a while (maybe after changing branches too often) Eclipse gets confused. Deleting the projects (not their contents) and re-importing fixes it every time. Typically, I have needed to do this about once every two months. No big deal! Import is done within Eclipse via the Import->Gradle Project -> build model process.
I needed to do this again recently after upgrading to the latest packages. Now compilation and execution (running Unit Tests for instance) within Eclipse works fine; but debug has lost all the inter-project dependencies. I can no longer set a breakpoint on code in Project 2 and run something from Project 1 and have the source code display. Instead, I get the "Edit Source Lookup Path" window when the breakpoint is hit.
I have Eclipse Luna Release 2, version 4.4.2, Spring IDE 3.6.4.201503051146-RELEASE, and Gradle IDE 3.6.4.201503050952-RELEASE. My gradle wrapper is version 2.3.6, and I am on a Mac OS X 10.10.3
The previous .classpath files looked like:
<classpath>
<classpathentry kind="src" output="build/classes/main" path="src/generated/java"/>
<classpathentry kind="src" output="build/classes/main" path="src/main/java"/>
<classpathentry kind="src" output="build/resources/main" path="src/main/resources"/>
<classpathentry kind="src" output="build/classes/test" path="src/test/java"/>
<classpathentry kind="src" output="build/resources/test" path="src/test/resources"/>
<classpathentry exported="true" kind="src" path="/proj1.main"/>
<classpathentry exported="true" kind="src" path="/proj2.main"/>
<classpathentry exported="true" kind="src" path="/proj3.main"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
<classpathentry kind="output" path="target"/>
which has three dependent projects then show up on the Java Build Path, Projects tab. Now, none show up but the projects appear under Gradle Dependencies on the Libraries tab (so compiling and running still works).
I imported the same way I have for over two years, so that is not it. Additionally, there are some new options on the Preferences->Gradle tab. I tried with "Remap Jars to Gradle Projects" and "Use Custom Tooling Model).
Does anyone know how to make it work the way it has been working? I really do not want to generate the eclipse files from the command line.
try cleanEclipse and also check the .bin directory and see if the class files are there as this is how gradle plugin use to debug.
Hope that helps.

Project is Missing Required Source Folder: "src_ex_common"

I try to open the sample project from google opensource as provided in the following link:
https://android.googlesource.com/platform/packages/apps/Calendar.git
I have imported the 5 git repositories as required in the program but there is still a red exclamation mark near the project and the "Problems" suggested the project is missing required source folder "src_ex_common". I right click the project name => Properties => Java Build Path => Source, i saw
"MainProjectActivity/src_ex_common (missing)".
I right clicked the project name => new=>source folder and attempt to name a new folder called "src_ex_common" but eclipse said The folder is already a source folder. Then i tried to name a new folder called "src_ex_common" in Windows. The problem above is solved but there are many errors then appear in various java files under src.
I googled that some said this might be due to the problem in ".classpath"
The detail of .classpath is listed below:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src_ex_common"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
Did anyone encounter this problem before? Great if u would share your approach to tackle it. Many thanks!
If you open the mkprojectfile file in the root folder, you will see that the src_ex_common folder is linked to the commons library:
<link>
<name>src_ex_common</name>
<type>2</type>
<location>SRC_ROOT_DIR/frameworks/ex/common/java</location>
</link>
You can import this project from the same ex repository that contains the chips dependency.

Build Spring Roo / Export maven project with Eclipse Export -> Runnable JAR file

I have Maven project created with Spring roo in STS 2.5.1.RELEASE (It is Eclipse 3.6.1 + Spring tools + m2eclipse). I have second simple Java project on build path. Everything is working ok within Eclipse.
Now the problem is to build. I cannot do so with maven, because it also requires that referenced project is maven project. For referenced project I just use Eclipse Export -> Runnable JAR file to export and generate ant file for next build.
Doing so for first project, I get runtime error, even though META-INF/spring/applicationContext.xml is both is .jar and in the folder next to .jar
2011-02-19 13:58:39,135-org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/applicationContext.xml]
2011-02-19 13:58:39,405-org.springframework.core.io.support.PathMatchingResourcePatternResolver - Cannot search for matching files underneath URL [rsrc:com/company/test/] because it does not correspond to a directory in the file system
java.io.FileNotFoundException: URL [rsrc:com/company/test/] cannot be resolved to absolute file path because it does not reside in the file system: rsrc:com/company/test/
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:204)
Referenced project is under heavy development, and I cannot move, refactor it or change its nature.
Maven project with Spring roo is parallel version to be developed.
How to build maven project with included eclipse project?
Example.
Project /RooInheritanceMaven has project /RooInheritanceJava on its (eclipse) build path.
.classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/RooInheritanceJava"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
It is incompatibility between Eclipse Export to Executable JAR and Spring.
To be more exact it is
org.springframework.core.io.support.PathMatchingResourcePatternResolver
Similar provlem was before. see
#SPR-3815 Classloader problem - Spring Projects Issue Tracker
try
jar -tf PersonApp.jar >PersonApp.jar.txt
The solution is to extract .classes and all stuff from jar into folder
jar xf PersonApp.jar
and run as
set CLASSPATH=D:\TEMP\KDF.MSSQL\antlr-2.7.6.jar;D:\TEMP\KDF.MSSQL\aopalliance-1.0.jar; <... all jar dependecies listed>
java com/company/PersonApp
Look at onejar-maven-plugin http://blog.jayway.com/2009/03/22/executable-jar-with-onejar-maven-plugin/
Use the Roo command
perform package
to get your application bundled - so that you can deploy it into your own container.

precedence of persistence.xml in hibernate project

I have an eclipse project with several jars for JPA / Hibernate. One of tham contains a META-INF/persistence.xml and I want to override that by defining my own persistence.xml. So I tried using my persistence.xml in src/persistence.xml also src/META-INF/persistence.xml but everytime it seems jar/META-INF/persistence.xml gets picked up.
I also tried editing .classpath file of eclipse projects and moved up classpathentry path="bin" higher up than the library included but still its not picking up my persistence.xml
<classpath>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/main/rules"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="con" path="DROOLS/Drools"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/drools"/>
</classpath>
In the tutorial I read:
You will need to override these
defaults if you want to change them,
by adding your own persistence.xml in
your classpath, preceding the default
one in drools-persistence-jpa.jar
So I tried using my persistence.xml in src/persistence.xml also src/META-INF/persistence.xml but every time it seems jar/META-INF/persistence.xml gets picked up.
The persistence.xml should be located under META-INF/persistence.xml so the first attempt won't work. And when I look at your .classpath file, I don't see src as source path so the second attempt won't work either.
Try src/main/java/META-INF/persistence.xml instead.
Actually, your project layout really looks like a Maven layout and with Maven, resources typically go to src/main/resources or src/test/resources. But since you didn't mention what tutorial you're following, I can't confirm if this applies here.
Anyway, my suggestion should work.