问题如下:
我安装并运行了第 3 方 Eclipse 插件
上面的 Eclipse 插件提供了某种“扩展点” - 一个我可以在插件 lib 目录中扩展/重写和替换的类的源代码(我并不是说这是一个好主意,但必要性让我们做一些事情我们并不为此感到自豪 - 内部开发有其怪癖)
这里的想法是将任何此类更改包含在外部 JAR(由我们创建)中,以便代码中的任何更改都不需要我们在开发过程中重新启动 Eclipse 来“刷新”“扩展点”类。
最终,将创建一个插件/捆绑包并将其作为原始插件的依赖项放置 - 这样安装和使用该插件实际上就可以工作。
问题是 - 我可以以某种方式将外部 JAR 文件添加到 Eclipse 应用程序调试/运行配置中吗?
通常,将 JAR 添加到类路径选项卡适用于常规 Java 应用程序调试/运行。然而,Eclipse 应用程序没有该选项卡。
到目前为止,我们的努力(失败了,可能是由于一些愚蠢的语法错误或其他原因)包括:
Bundle-ClassPath:插件的依赖项C:\test.jar这些都没有任何区别 - 引用 JAR 文件中的类的“扩展点”中的代码失败 - 异常归结为:
Caused by: java.lang.ClassNotFoundException: test.Test
at org.eclipse.osgi.internal.loader.BundleLoader.
findClassInternal(BundleLoader.java:506)
Run Code Online (Sandbox Code Playgroud)
任何指示/帮助/批评将不胜感激。
更新
显然,将 JAR 放在插件的 lib 目录中并更新 MANIFEST 文件不起作用(并不是说它对我有帮助 - 因为这样的解决方案需要“刷新”,这是我在第一个尝试避免的地方),所以我一定是做了一些根本错误的事情。
这有任何意义吗?还是我在其中一次尝试中错过了一些东西?
我尝试使用以下代码连接到本地 MySQL 服务器:
dbURL = "jdbc:mysql://localhost:3306:/" + dbname;
try{
Class.forName("com.mysql.jdbc.Driver");
try{
con = DriverManager.getConnection(dbURL, dbuser, dbpass);
} catch (SQLException ex){
System.out.println("ERROR: Could not connection to SQL DB");
con = null;
}
} catch (ClassNotFoundException e){
System.out.println("Error: ");
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
然后我得到
java.lang.ClassNotFoundException:com.mysql.jdbc.Driver
我了解到Java无法找到正确的驱动程序来将Java环境连接到MySQL数据库。这是在 Windows 7 系统上编译并移植到 Ubuntu 11.04 系统上。
有没有一种特定的方法可以使用特定的类路径运行 Java 程序,例如:
java -cp /usr/share/java/mysql-connector-java.jar program.jar
Run Code Online (Sandbox Code Playgroud)
当我尝试时,这不起作用。
我正在开发一个 Android 项目 - 到目前为止一切顺利。今天我向项目中添加了一些额外的 Java 代码 - 我将在这里将其称为 calcCode。这是一些在后台进行计算的代码,并非 Android 特定的 - 我将在我的项目中使用它。
我将该新代码添加到与同一项目下的 Android 代码不同的包中。
所以我所拥有的是:
Project
AndroidPackage
AndroidCode
SomeJaveCodePackage
UtilityCode
Run Code Online (Sandbox Code Playgroud)
由于某种原因,当我尝试调试 calcCode 时,我收到了这个恼人的未找到源错误。尽管如此,代码仍一如既往地运行并提供正确的结果。我从其他项目中获取了 calcCode 并将这些文件复制到我的新 Android 项目中。当我看不到源代码时,我删除了所有 calcCode 文件并手动创建它们,首先在相关包下创建一个类文件,然后将代码复制粘贴进去。我认为这将有助于 Eclipse 识别类的路径。
我还尝试:“编辑源查找路径”并添加我试图调试的类的源代码。
这没有改变任何东西 - 我仍然无法调试代码。我在 StackOverflow 上读到了这个问题的几个答案。大多数与 Junit 和 Tomcat 打交道,我遵循了他们的建议,但这并没有改变情况。
任何人都知道为什么会发生这种情况?
我有 Eclipse Indigo。
在 m0skit0 的评论后编辑:谢谢 m0skit0 的帮助。我只想问一个问题(我可能在路上混淆了一些东西)。我的问题是:为什么 Eclipse 在调试时找不到我自己的代码。它曾经在以前的项目中工作过(我能够在调试过程中跟踪代码完成应用程序的所有过程)。
我所做的就是设置一个断点
Tour myTour = new Tour("res/raw/td.csv", "readCSV");
Run Code Online (Sandbox Code Playgroud)
游览是我自己的手工课。当我按 F5 以便进入它时,我收到错误:java.lang.ClassNotFoundException,并且在代码窗口中我收到“未找到源”和一个“编辑源查找路径”按钮。
这是调用堆栈:
Thread [main] (Suspended)
ClassNotFoundException(Throwable).<init>(String, Throwable) line: 286
ClassNotFoundException(Exception).<init>(String, Throwable) line: not available
ClassNotFoundException(ReflectiveOperationException).<init>(String, Throwable) …Run Code Online (Sandbox Code Playgroud) 在 Ant 中,如果我有一个单独的已编译 CLASS 文件位于我的项目中(比如 at ,当我目前有以下内容时gen/stragglers/SomePOJO.class,有没有办法专门将该类文件添加到我的<javac>编译类路径中:
<javac includeantruntime="false" srcdir="src/main/java"
destdir="gen/bin/main">
<classpath refid="main.compile.path"/>
</javac>
Run Code Online (Sandbox Code Playgroud)
如果不是,为什么?如果是这样,如何?提前致谢!
我在 Android 应用程序中使用 Mashape 的 API。Mashape 推荐使用 Unirest 库。我已经包含了 unirest 链接中提到的依赖项:http ://unirest.io/java
我的依赖:
compile fileTree(dir: 'libs', include: ['*.jar'])
compile group:'com.mashape.unirest', name:'unirest-java', version:'1.3.26'
compile group:'org.apache.httpcomponents', name:'httpcore', version:'4.3.3'
compile group:'org.apache.httpcomponents', name:'httpclient', version:'4.3.6'
compile group:'org.apache.httpcomponents', name:'httpasyncclient', version:'4.0.2'
compile group:'org.apache.httpcomponents', name:'httpmime', version:'4.3.5'
compile group:'org.json', name:'json', version:'20141113'
compile 'com.android.support:appcompat-v7:21.0.+'
Run Code Online (Sandbox Code Playgroud)
当我发出 HTTPRequest 时,我仍然收到此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/conn/HttpClientConnectionManager
at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:153)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:133)
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
Disconnected from the target VM, address: '127.0.0.1:58805', transport: 'socket'
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.HttpClientConnectionManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method) …Run Code Online (Sandbox Code Playgroud) 在 java 程序中,当我尝试编译一些代码时,它会创建一个错误,我收到以下消息:
Picked up _JAVA_OPTIONS: -Xmx512M
这是什么类型的错误抑制“Picked up _JAVA_OPTIONS”消息 的页面
无法解决问题,如何在 Windows 7 中更改系统变量?
当我尝试执行我的 aws lambda function
1) Error injecting constructor, java.lang.NullPointerException
at in.nikhilbhardwaj.path.route.resources.ServicesResource.<init>(ServicesResource.java:66)
at in.nikhilbhardwaj.path.route.resources.ServicesResource.class(ServicesResource.java:56)
while locating in.nikhilbhardwaj.path.route.resources.ServicesResource
for parameter 0 at in.nikhilbhardwaj.path.alexa.intent.HelloWorldIntentAction.<init>(HelloWorldIntentAction.java:44)
while locating in.nikhilbhardwaj.path.alexa.intent.HelloWorldIntentAction
while locating in.nikhilbhardwaj.path.alexa.intent.IntentAction annotated with @com.google.inject.multibindings.Element(setName=,uniqueId=10, type=MAPBINDER, keyType=java.lang.String)
at in.nikhilbhardwaj.path.alexa.intent.IntentModule.configure(IntentModule.java:17) (via modules: in.nikhilbhardwaj.path.alexa.AlexaStarterApplicationModule -> in.nikhilbhardwaj.path.alexa.intent.IntentModule -> com.google.inject.multibindings.MapBinder$RealMapBinder)
while locating java.util.Map<java.lang.String, in.nikhilbhardwaj.path.alexa.intent.IntentAction>
for parameter 0 at in.nikhilbhardwaj.path.alexa.intent.IntentHandlerServiceImpl.<init>(IntentHandlerServiceImpl.java:16)
while locating in.nikhilbhardwaj.path.alexa.intent.IntentHandlerServiceImpl
while locating in.nikhilbhardwaj.path.alexa.intent.IntentHandlerService
for parameter 0 at in.nikhilbhardwaj.path.alexa.AlexaStarterSpeechlet.<init>(AlexaStarterSpeechlet.java:26)
while locating in.nikhilbhardwaj.path.alexa.AlexaStarterSpeechlet
Caused by: java.lang.NullPointerException
at java.io.Reader.<init>(Reader.java:78)
at java.io.InputStreamReader.<init>(InputStreamReader.java:113)
at in.nikhilbhardwaj.path.route.resources.ServicesResource.initializeServiceIds(ServicesResource.java:88)
at in.nikhilbhardwaj.path.route.resources.ServicesResource.<init>(ServicesResource.java:68)
at in.nikhilbhardwaj.path.route.resources.ServicesResource$$FastClassByGuice$$3d6e91ec.newInstance(<generated>)
Run Code Online (Sandbox Code Playgroud)
我已经classpath按照 …
我正在运行一个应用程序(在 Windows 上的 GitBash 中):
mvn spring-boot:run
Run Code Online (Sandbox Code Playgroud)
除了应用程序正在寻找一个属性文件,我想让它在类路径中可用。但我不想更改此应用程序中的任何代码。
有没有办法在运行此命令时指定其他类路径?我尝试了各种形式:
mvn spring-boot:run -Dclasspath="C:\\path\\to\\config\\dir"
Run Code Online (Sandbox Code Playgroud)
或者
mvn spring-boot:run -Dclasspath=/C/path/to/config/dir
Run Code Online (Sandbox Code Playgroud)
我试过设置$CLASSPATH.
这些都不起作用,但我不清楚它在哪里中断,因为唯一的错误是找不到我的属性文件。
我已经编译了类文件shortScreen/out/production/classes/com/rsw/并希望在 clojure repl 中使用它们。我认为挂断已经开始,add-classpath但我不熟悉应该发生什么。或者怎么解决。
(use '[cemerick.pomegranate :only (add-dependencies add-classpath)])
(import 'clojure.pprint)
(def myclasses "shortScreen/out/production/classes/com/rsw/")
; do i have the correct path?
(-> (clojure.java.io/file myclasses) (file-seq) (pprint)) ; shows many class files
(.exists (clojure.java.io/file myclasses "util.class")) ; true
; add the path
(add-classpath myclasses)
; but nothing like myclasses path in list
(def thiscp (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))
(pprint thiscp)
(filter (fn [s] (re-seq #"out" s)) ;myclasses path should match "out"
(for [x thiscp]
(.toString x)))
; fails -- …Run Code Online (Sandbox Code Playgroud) 我是 Spring Boot 和开发的新手。在 kotlin 和 gradle 中使用 Spring Boot 2。当我尝试附加 ssl 证书时出现类路径错误。Spring Boot 1.4解决方案:类路径资源 [] 无法解析为 URL,因为它不存在不起作用。
同时,我尝试复制解决方案并删除了 starter-data-jpa 的实现并使用了 starter-jdbc。但似乎没有任何效果。另一个解决方案也会引发相同的错误。
> Error starting ApplicationContext. To display the conditions report
> re-run your application with 'debug' enabled. 2019-01-16 23:20:19.511
> ERROR 9589 --- [ main] o.s.boot.SpringApplication
> : Application run failed
>
> org.springframework.context.ApplicationContextException: Unable to
> start web server; nested exception is
> org.springframework.boot.web.server.WebServerException: Could not load
> key store: class path resource [keystore.p12] …Run Code Online (Sandbox Code Playgroud)