首页 \ 问答 \ 应该在lib / ext中放置一个jar文件而不是在Windows XP上使用CLASSPATH吗?(Should putting a jar file in lib/ext work instead of using a CLASSPATH on Windows XP?)

应该在lib / ext中放置一个jar文件而不是在Windows XP上使用CLASSPATH吗?(Should putting a jar file in lib/ext work instead of using a CLASSPATH on Windows XP?)

我有两个jar文件,A.jar和B.jar。 A包含我的main函数,它依赖于B中定义的类。

我将A和B放在同一个文件夹中,该文件夹位于Windows PATH中,并尝试在A中运行我的主...

java -jar A.jar -dosomething

这给了我一个B方法的java.lang.NoClassDefFound错误,我在-dosomething下面的代码中调用它。 有趣的是,它找到了A.jar并调用了main方法,但它找不到B.jar,即使它与A.jar位于同一个文件夹中。

所以我(再次)阅读了关于CLASSPATHs和JAVA_HOME变量的内容,并确保我的JAVA_HOME指向正确的位置。 这个文档描述了我应该如何将我的扩展jar文件(在我的案例B中)放入/ lib / ext文件夹中,所以我尝试了,但是我得到了相同的java.lang.NoClassDefFound错误。

我使用的是Java jdk1.5.0_10,所以为了更好的衡量,我还将B.jar放在了jre / lib / ext文件夹下面。

所以现在我有三个地方,PATH上的本地文件夹,JAVA_HOME / lib / ext和JAVA_HOME / jre / lib / ext,我仍然得到同样的错误。

应该使用lib / ext工作吗? 我到底在哪里放置我的B.jar文件才能正常工作?


I have two jar files, A.jar and B.jar. A contains my main function and it relies on classes defined in B.

I put A and B in the same folder, which is in the Windows PATH, and try and run my main in A...

java -jar A.jar -dosomething

This gives me a java.lang.NoClassDefFound error on a method of B that I call in the code underneath -dosomething. Interestingly it has found A.jar and called the main method, but it can't find B.jar, even though it is in the same folder as A.jar.

So I read around (again) about CLASSPATHs and the JAVA_HOME variable and I made sure that my JAVA_HOME is pointing to the right place. This document describes how I should be able to put my extension jar file(s), in my case B, into the /lib/ext folder, so I tred that, but I get the same java.lang.NoClassDefFound error.

I am using Java jdk1.5.0_10, so for good measure I also placed B.jar in the jre/lib/ext folder underneath there.

So now I have it in three places, the local folder on the PATH, JAVA_HOME/lib/ext and JAVA_HOME/jre/lib/ext and I still get the same error.

Should using lib/ext work? Where on earth have I got to put my B.jar file for this to work properly?


原文:https://stackoverflow.com/questions/8773081
更新时间:2022-11-26 21:11

最满意答案

由于electron是基于node的,因此您可以在主进程JS文件和项目使用的任何JS文件中使用require

// main.js or something
let myModule = require("./myModule");

// myModule.js
....
module.exports = function() {}; // or whatever you want to share with main.js

Since electron is node based, you can use require both in your main process JS file and in any JS file your project uses.

// main.js or something
let myModule = require("./myModule");

// myModule.js
....
module.exports = function() {}; // or whatever you want to share with main.js

相关问答

更多
  • 将JS文件放在“js”文件夹中,在XML布局中可以将其包含在: 希望有所帮助。 编辑:你也可以在你的区块中做到这一点: protected function _prepareLayout() { $this->getLayout()->getB ...
  • 每个说法没有“标准尺寸”,但始终保持文件大小最小化始终是好的。 例如,Gmail,谷歌地图等,加载了许多MB的Javascript。 JS文件越少,一般情况就越好,因为服务它们的Web服务器的连接数量会减少,从而导致负载减少。 不,混合缩小和未缩小的文件应该不是问题。 JSMin和UglifyJS是流行的压缩器。 您应该将执行附加到适当的事件(例如document.ready以便脚本不会因为页面未完全加载而停止工作。 There is no "standard size" per say, but it's ...
  • 由于electron是基于node的,因此您可以在主进程JS文件和项目使用的任何JS文件中使用require 。 // main.js or something let myModule = require("./myModule"); // myModule.js .... module.exports = function() {}; // or whatever you want to share with main.js Since electron is node based, you can ...
  • 将其作为参数传递: 在test.js中: function func(param){ console.log(param); // contents of $var } 或者全局设置: Pass it as a parameter:
    通过终端执行此命令--- npm install jquery --save, npm install --save-dev @types/jquery 将myExternal.js文件移动到assets文件夹 Execute this command through terminal --- npm install jquery --save, npm install --save-dev @types/jquery move myExternal.js file to assets folder ...
  • 以下代码正常工作: - 在您的代码中,您错过了右括号“)”接近“if condition” demo Here is working solution for .html and .js fil ...
  • 你有一个问题,因为你不逃避双引号: htmlcode = "

    OHMs LAW EXPERIMENT

    "; 你应该考虑对你的字符串使用简单的引号,这样你就不必转义双引号: htmlcode = '

    OHMs LAW EXPERIMENT

    '; 其他建议,你应该使用“+ =”符号 htmlcode = '
  • 如果上面的代码是Javascript.js文件中的唯一内容,那么您需要调用函数来运行代码。 您已正确包含外部Javascript文件 - 但是,因为所有JS都包含在函数中,所以必须在代码运行之前调用这些函数。 从PHP文件中调用'ClearForm()'或'comeBack()'应该运行代码。 If the above code is the only thing in your Javascript.js file, then you need to call the functions to run t ...
  • 首先,绝对路径必须有效。 这不是Netbeans或Glassfih或JSF的问题 - 它是一个浏览器的东西。 如果您的浏览器出现故障阻止它从有效网址中获取Javascript,您会注意到。 因此,如果您的Javascript没有加载,那么99%的可能性是一个简单的错误,一个愚蠢的错误(忘记目录名称,添加额外的斜杠或类似的东西),与任何提到的技术无关。 另一个理论(只是一个理论 - 我没有足够的数据来证明它)是你有一个标准的映射,显示“虚拟”面目录( / faces / *)中的所有面部文件。 因此,当您将i ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。