I have deleted the earlier version of eclipse I was using also updated the selenium 3.0.1, also added all the .jar files but now I'm getting a new error.
"The import org cannot be resolved"
Below is the code:
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class findByLinkedText {
public static void main(String[] args) {
System.setProperty("Webdriver.gecho.driver",
"C:\\Users\\lsharma1\\Desktop\\Selenium Drivers\\Gecho
driver\\ gechodriver.exe ");
WebDriver driver = new FirefoxDriver();
drive.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); String URL = "https://www.google.co.in/"; driver.get(URL); driver.close();
}
}
use this maven dependency in your pom :
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.3.1</version>
</dependency>
It is not recognizing this org package.
Hope that helps you.
May be the problem is that your selenium dependency has not been downloaded in your users/usename/.m2 folder.
Related
I just did fresh install of Eclipse & JBoss Tools but can't get the EL autocomplete to work. I tracked it down to the use of Jakarta API. If I use the older JavaEE API, the EL autocomplete works as expected, but nothing is displayed when using the Jakarta API in the pom.
Eclipse Version 2022-12 (4.26.0) using vm: JDK 17.0.4.1
JBoss Tools Version 4.26.0 Final (Installed from Marketplace)
Example using Jakarta
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
.
package test;
import java.io.Serializable;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
#Named
#ViewScoped
public class JakartaNamedObject implements Serializable {
private static final long serialVersionUID = 1L;
//getters and setter
}
Example using Javax
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
.
package test;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import java.io.Serializable;
#Named
#ViewScoped
public class JavaxNamedObject implements Serializable {
private static final long serialVersionUID = 1L;
//getters and setter
}
I used the Eclipse installer to install Eclipse 2022-12, with a brand new workspace and then Eclipse Marketplace to install JBoss Tools 4.26.
I guess the question is does EL autocomplete work with Jakarta and if so why is it not working in my fresh new setup?
I am learning to hibernate so I made a small app for crud operation using mySQL as database. However, I am getting some errors and I cannot find the solution anywhere. SDK 17.0.2, I am not using maven , Also all hibernate final jar files have been added
my class:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.luv2code.hibernate.demo.entity.Student;
public class CreateStudentDemo {
public static void main(String[] args) {
// Create session factory
SessionFactory factory= new Configuration()
.configure("hibernate.cfg.xml")
.addAnnotatedClass(Student.class)
.buildSessionFactory();
//Create session
Session session = factory.getCurrentSession();
try {
//Create a Student object
System.out.println("Creating new student");
Student tempStudent = new Student("Pau;", "Wall", "paul#luv2code.com");
//Start a transaction
session.beginTransaction();
//save the student object
session.save(tempStudent);
//commit transaction
session.getTransaction().commit();
}
finally {
factory.close();
}
}
}
runtime error :
java.security.PrivilegedActionException: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because "com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass" is null
java removed java.xml.bind from JAVA 9 and higher editions.
You need to add these jar files manually to your library
basically you can to that in this way.
If you use Intellij this is the easyest way:
jaxb-impl-2.3.0.jar
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
jaxb-core-2.3.0.jar
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
jaxb-api-2.3.1.jar
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
javax.activation-api-1.2.0.jar
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
If you use intellij here is a step my step to get these files through IDE
go to project structure:
Libraries, and click + sign
Chick to from Maven:
Paste these dependencies to the search.
It will automatically find exact jar files to download, Kist Paste it and click to the enter that is it.
Also later you can just add these files to the classpath just in case:
java removed java.xml.bind from JAVA 9 and higher editions.
Here is the eclipse solution:
In Eclipse IDE:
Download these jar files and paste them inside lib folder:
Go the project properties: The last line
Done these steps:
Happy Coding! :)
in my maven project, i have added the testng dependency as below:
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
But, then when i write a simple test as below, it cannot find #Test :
public class Test{
#Test
public void test() {
}
}
it complains with Test is not an annotation type
i tried to add the test manually by the below line:
import org.testng.annotations.Test;
but again it complains with:
The import org.testng.annotations.Test conflicts with a type defined in the same file
I have Forced Update my project by maven several times but still no success.
It is not working because your class name also the "Test" so, you have to change the class name then only #Test annotation will work.
Remove scope tag from respective dependency in pom.xml. It shall work.
Hi I'm having a bit of trouble using the Apache POI library in java. I've downloaded and imported the library into my project, but am unable to import it into my java class. (like you would do):
import java.awt.*;
Am I looking at this the wrong way, or am I missing something?
If you are using maven, map de dependecies:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
Then import and use the apache poi library:
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
//..
FileInputStream file = new FileInputStream(new File("C:\\test.xls"));
Hello i'm new in neo4j and i would like to use OSM + Neo4j Spatial.
I have a maven project and my Neo4j version is 2.3.0-M01
I have a simple code just for importing an OSM file but it displays some errors in the import files: GraphDatabaseService, EmbeddedGraphDatabase and BatchInserter.
package testOSM;
import java.nio.charset.Charset;
import org.neo4j.gis.spatial.osm.OSMImporter;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.kernel.impl.batchinsert.BatchInserter;
public class TestOsm {
private static final String DB_PATH = "/community/data/graph.db";
public static void main(final String[] args){
OSMImporter importer = new OSMImporter("clz_map.osm");
importer.setCharset(Charset.forName("UTF-8"));
BatchInserter batchInserter = BatchInserter.inserter(DB_PATH);
try{
importer.importFile(batchInserter, "clz_map.osm", false);
GraphDatabaseService db = new EmbeddedGraphDatabase(DB_PATH);
importer.reIndex(db);
db.shutdown();
}
catch(Exception e){
System.out.println(e.getMessage());
}
batchInserter.shutdown();
}
}
May be my problem is with the versions, because i'm using Neo4j 2.3-M01, but i don't know exactly how should i set the versions e.g. here
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-graph-collections</artifactId>
<version>0.7.1-neo4j-2.0.2-SNAPSHOT</version>
<type>jar</type>
</dependency>
My pom.xml is based on https://github.com/neo4j-contrib/spatial/blob/master/pom.xml
Plus:
<repository>
<id>neo4j</id>
<url>http://m2.neo4j.org/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>2.3.0-M01</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>2.3.0-M01</version>
</dependency>
You can have a look into my git repository
https://github.com/amhg/OSM
Thank you in advance!
For anyone else that runs into this, here is how to do it: https://github.com/maxdemarzi/OSM
Notice a small differences between 2.2.x and 2.3 (7/30-currently on M2).
Just needed the right dependencies.
there are API changes since the last released version. Looking at https://github.com/neo4j-contrib/spatial/blob/master/pom.xml#L4 , it seems you can use Neo4j 2.2.3 if you build that project yourself with
mvn install
and then include version 0.15-neo4j-2.2.3 of the spatial plugin into your pom.xml from the local mvn repo.
I took a look at your pom.xml and it looks like you copied the pom.xml from Neo4j Spatial. This is not what you want.
Since you are trying to write a new application that uses Neo4j Spatial, you should have a pom that is new and refers to neo4j-spatial as a dependency, not a pom that is in any way similar to the neo4j-spatial pom. There is a section in the README that describes how to add neo4j-spatial as a dependency to your own pom.
So I would suggest you do the following:
create a new pom.xml - https://maven.apache.org/guides/getting-started/index.html#How_do_I_make_my_first_Maven_project
then add the dependency as described in https://github.com/neo4j-contrib/spatial#using-neo4j-spatial-in-your-java-project-with-maven