我想简化执行调用Oracle数据库的Groovy脚本的过程.如何将ojdbc jar添加到默认的类路径中,以便我可以运行:
groovy RunScript.groovy
Run Code Online (Sandbox Code Playgroud)
代替:
groovy -cp ojdbc5.jar RunScript.groovy
Run Code Online (Sandbox Code Playgroud) Eclipse有一个带有Classpath选项卡的Run Configurations屏幕.
我在此选项卡的"用户条目"部分列出了一些jar,但是我的项目在我将这些jar文件复制到"bootstrap entries"部分之前没有运行.在两个部分中列出了罐子后,项目成功运行.
为什么?
这两种不同类别的Classpath设置有什么区别?
有没有办法迭代类路径中的所有类?
我想对实现某个接口的某些类进行一些反思性检查,但我想完全动态地完成它,而不需要检查哪些类,只需浏览类路径.
我创建了一个自定义SSLSocketFactory类并将其设置如下
ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl");
ldapEnv.put(FACTORY_SOCKET, socketFactoryClass);
LdapContext ldapContext = new InitialLdapContext(ldapEnv, null);
Run Code Online (Sandbox Code Playgroud)
它从Eclipse Dev Environment运行时运行正常,并从命令提示符运行它作为Jar文件.但是当我将其包装在服务包装器中并将其作为Windows服务启动时,它不起作用.我得到以下异常,
javax.naming.CommunicationException: 192.168.100.22:636 [Root exception is java.lang.ClassNotFoundException: com/testing/diraccess/service/ActiveDirectory$TestSSLFactory]
at com.sun.jndi.ldap.Connection.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapClient.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapClient.getInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.ldap.InitialLdapContext.<init>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com/testing/diraccess/service/ActiveDirectory$TestSSLFactory
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.jndi.ldap.VersionHelper12.loadClass(Unknown Source)
at com.sun.jndi.ldap.Connection.createSocket(Unknown Source)
... 35 more
Run Code Online (Sandbox Code Playgroud)
任何帮助???
如果我在同一目录中有两个单独的未编译的scala文件:
// hello.scala
object hello {
def world() = println("hello world")
}
Run Code Online (Sandbox Code Playgroud)
和:
// do.scala
hello.world()
Run Code Online (Sandbox Code Playgroud)
运行do.scala时出错:
$ scala do.scala
error: not found: value hello
Run Code Online (Sandbox Code Playgroud)
相反,我必须首先编译hello.scala文件并将其放在类路径上以使其工作:
$ scalac hello.scala
$ scala -cp hello do.scala
hello world
Run Code Online (Sandbox Code Playgroud)
有没有办法让一个脚本使用import,package,classpath,scala命令行工具或其他东西正确使用来调用另一个未编译的scala文件?
我仍然是Clojure的新手所以我很抱歉这是一个全新的问题,但我无法在网上找到足够的答案.
基本上,我的问题是,每当我尝试运行我的项目时,我都会收到如下错误:
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate greeter__init.class or greeter.clj on classpath:
Run Code Online (Sandbox Code Playgroud)
在这种情况下,greeter.clj在项目中与包含我的main函数的文件位于同一目录中.
为了便于说明,我创建了一个具有如下目录树的项目:

我的core.clj代码如下:
(ns omg.core
(require [greeter]))
(defn -main[] (greet))
Run Code Online (Sandbox Code Playgroud)
我的greeter.clj代码是:
(ns greeter)
(defn greet [] println("Hello world"))
Run Code Online (Sandbox Code Playgroud)
每当我输入时,lein run -m omg.core我都会得到上面提到的异常.我究竟做错了什么?
我已经看到一些Spring代码使用classpath:/some/path/to/resourceURL协议直接从运行时类路径读取配置文件和其他资源.
这是Spring构造还是Java构造?
除了这个问题,我找不到任何文档 - 从Java中的类路径加载资源的URL,这并不表示任何一种方式.
如果它是Java构造,那么有人能指出我的官方文档吗?
我知道这个问题有很多重复,但我已经看过了所有问题,但没有一个能解决这个问题.
我正在尝试运行一个具有main函数的类.我已经清理了项目,检查了类路径'.',将bin文件夹添加到运行配置下的类路径中.我不确定还有什么可以尝试,因为该类肯定在源文件夹中.
有人可以帮我解决这个问题吗?
package testIt;
public class MemoryVisualizerApp extends Application{
public static void main(String[] args) {
launch(args);
}
//Setup the scene and launch with given properties
@Override
public void start(Stage primaryStage) throws IOException{
Parent root = FXMLLoader.load(getClass().getResource("/MemoryVisualizer.fxml"));
Scene scene = new Scene(root, 650, 300);
//Set whether the screen should be re-sizable (possibly best size = default)
primaryStage.setResizable(true);
primaryStage.setMinHeight(300);
primaryStage.setMinWidth(550);
primaryStage.setTitle("Memory Usage");
primaryStage.setScene(scene);
scene.getStylesheets().add("testIt/MemoryVisualizer.css");
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>()
{
public void handle(WindowEvent e){
/*Currently the threads continue running after window is closed. Looking …Run Code Online (Sandbox Code Playgroud) 我遇到了关于连接到H2的问题
这是我的pom.xml:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>.</groupId>
<artifactId>dbConnection</artifactId>
<name>Db Connection</name>
<packaging>war</packaging>
<version>0.1</version>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.176</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
这是我的主要代码
import java.sql.*;
public class DbConnection
{
static final String DB_URL = "jdbc:h2:tcp://localhost/~/test;AUTO_SERVER=TRUE";
public static void main(String[] args) throws Exception
{
try
{
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection(DB_URL,"sa","");
conn.close();
}
catch(ClassNotFoundException ex)
{
System.out.println( "ERROR: Class not found: " + ex.getMessage());
}
}
}
Run Code Online (Sandbox Code Playgroud)
总是显示未找到的类:org.h2.Driver
当我发出命令"react-native run-android"时,它发生了:
FAILURE:构建因异常而失败.
无法解析配置':classpath'的所有文件.找不到com.android.tools.build:gradle:3.0.1.在以下位置搜索: https: //jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle -3.0.1.pom https://jcenter.bintray.com/com/android /tools/build/gradle/3.0.1/gradle -3.0.1.jar
截图: