import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
I try to import these two pacakges into spring boot java program. But I got the following error:
package javax.script does not exist.
I know I need to write down the dependency into pom.xml such as here
But I don't know exactly what do I need to write.
Related
I have a java project built with maven and jdk 1.8. Some classes use javax.naming.* and javax.xml.* classes in the jdk.
From Java 9 onwards those javax packages have been removed from the jdk. So how do I upgrade the project to run on java 9 or later?
Here are the classes,
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.NoInitialContextException;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.event.EventContext;
import javax.naming.event.EventDirContext;
import javax.naming.event.NamingListener;
import javax.naming.ldap.Control;
import javax.naming.ldap.ExtendedRequest;
import javax.naming.ldap.ExtendedResponse;
import javax.naming.ldap.LdapContext;
import javax.naming.spi.InitialContextFactory;
import javax.naming.spi.InitialContextFactoryBuilder;
import javax.naming.spi.NamingManager;
import javax.xml.namespace.QName;
I have found out jndi contains javax.naming.* classes. But I am not sure how to include them. Just adding as a maven dependency does not work.
These classes have not been removed, see the JavaDoc for javax.naming and javax.xml.namespace. Unless you are building a module and forgot to add the modules java.xml and java.naming as dependencies, the mistake lies outside of Java, most likely with the tooling.
To convince yourself, compile a simple class on the command line with javac and watch it work. Then make sure you are running recent versions of the involved tools (particularly build tool and IDE). If that's the case and the error persists, improve your question with a more detailed description of the error.
I am trying to use akka http v10.0.2. I added akka-http in my build.gradle file (just akka-http, not http-core or any other akka http related dependency). I tried using the imports below but the 'akka.http.javadsl.server' does not seem available (even though I can see the package when I download the jar file and extract it). The other packages are visible. I have tried clearing the IntelliJ cache. Barring clearing my ivy cache, are there any other steps I can take to troubleshoot this further?
import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.http.javadsl.ConnectHttp;
import akka.http.javadsl.Http;
import akka.http.javadsl.ServerBinding;
import akka.http.javadsl.model.HttpRequest;
import akka.http.javadsl.model.HttpResponse;
import akka.http.javadsl.server.AllDirectives;
import akka.http.javadsl.server.Route;
import akka.stream.ActorMaterializer;
import akka.stream.javadsl.Flow;
import java.util.concurrent.CompletionStage;
the issue was resolved by adding all the other akka http dependencies in my gradle build file. I will try to post the build file here when possible.
I have the following problem. In my ORMConfiguration file I am setting up some of the basic properties that I need to implement JPA. Inside this ORMConfig.java file, I also have a main class.
The class imports look like this
package io.good.asset.ams.dao.configuration;
import io.good.asset.ams.model.domain.Category;
import io.good.asset.ams.model.domain.Company;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import java.util.Map;
The project is built using gradle and depencies are set in the following manner:
project(':AMSRepository'){
dependencies {
compile project(':AMSModel')
compile("org.springframework.boot:spring-boot-starter-jdbc:${springBootVersion}")
compile("org.hibernate:hibernate-core:5.2.10.Final")
compile("com.h2database:h2:${h2Ver}")
testCompile("org.liquibase:liquibase-core:${liquibaseSpringVer}")
}
}
Since this is a multi-modular project the first two imports in my class are pointing to the different module, and when I try to build that complete project from root, or individual AMSRepository module i get error that
error: package io.good.asset.ams.model.domain does not exist
import io.good.asset.ams.model.domain.Category;
^
error: package io.good.asset.ams.model.domain does not exist
import io.good.asset.ams.model.domain.Company;
My settings.gradle looks like this
rootProject.name = 'AMS'
include 'AMSRepository'
include 'AMSService'
include 'AMSWeb'
include 'AMSModel'
I have also used IntelliJ module settings panel and tried to add manually decencies to this module troublesome module, and the most weird this is that nothing is underlined as wrong and that when I run the main class in ORMConfig.java and instantiate objects from these modules, everything works fine.
Like a war file, a Spring Boot application is not intended to be used
as a dependency. If your application contains classes that you want to
share with other projects, the recommended approach is to move that
code into a separate module. The separate module can then be depended
upon by your application and other projects.
Spring Boot Doc
I want to use neo4j libraries to connect my java app with neo4j database and follow the tutorials from http://neo4j.com/docs/stable/tutorials-java-embedded-hello-world.html.
At the beginning I copied the sources code from https://github.com/neo4j/neo4j/blob/2.2.2/community/embedded-examples/src/main/java/org/neo4j/examples/EmbeddedNeo4j.java and netbeans complains about missing libraries like:
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.io.fs.FileUtils;
I have searched libraries from http://search.maven.org/#search|ga|2|g%3A%22org.neo4j%22 site for example:
org.neo4j.graphdb
But can not find anywhere. Where can I find libraries?
You need the neo4j-kernel artifact and all of its (transitive) dependencies, see http://mvnrepository.com/artifact/org.neo4j/neo4j-kernel.
Have you looked at http://search.Maven.org and searched Neo4j?
I came across this sample code for handling file uploads with Netty, this looks perfect, just what I needed. Unfortunately I am having difficulty incorporating this class as many Netty API features are unresolved. One of them for example is io.netty.handler.codec.http.DiskFileUpload, I am unable to find this in any of the online API docs for 3.0,3.1.3.2.
The class I am having issues with is here:
https://github.com/netty/netty/blob/master/example/src/main/java/io/netty/example/http/upload/HttpUploadServerHandler.java
I have tried using netty-3.2.5.final, 3.3.1.final, 3.4.0.Alpha
Unresolved imports:
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.EndOfDataDecoderException;
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.ErrorDataDecoderException;
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.IncompatibleDataDecoderException;
import org.jboss.netty.handler.codec.http.HttpPostRequestDecoder.NotEnoughDataDecoderException;
import org.jboss.netty.handler.codec.http.InterfaceHttpData;
import org.jboss.netty.handler.codec.http.InterfaceHttpData.HttpDataType
import org.jboss.netty.handler.codec.http.HttpDataFactory;
import org.jboss.netty.handler.codec.http.DiskAttribute;
import org.jboss.netty.handler.codec.http.DiskFileUpload;
import org.jboss.netty.handler.codec.http.FileUpload;
import org.jboss.netty.handler.codec.http.DefaultHttpDataFactory;
import org.jboss.netty.handler.codec.http.Attribute
Any help appricated
When you see the org.jboss.netty namespace, that indicates v3.x
io.netty is used in v4.
Online documentation is located at http://netty.io/docs/
It's under master branch which is 4.0.0.Alpha1-SNAPSHOT from the pom.