如何显式添加一段代码到java项目中

发布于 2024-10-17 00:18:40 字数 265 浏览 3 评论 0原文

我正在使用 Net beans IDE,我想向我的项目添加一段代码,以使运行该项目的用户看不到源代码,我决定将该段代码导出为在eclipse中创建一个jar文件,然后将该jar文件添加到项目中。但不幸的是,Net beans 不允许我导入它。它说它正在期待一个 .或者当我插入时。它进入该类,我无法通过导入指令将该 jar 文件导入到项目中。 net beans中是否有一个命令可以从jar文件创建对象并访问jar文件的函数和类?您能给出该指令的格式吗?如果您知道更好的方法来完成这项任务,如果您与我分享,我会很高兴

I’m working with Net beans IDE and I want to add a piece of code to my project in a way that the source code won’t be visible to the user who is running the project, I decided to export that piece of code as a jar file in eclipse and then add that jar file to the project. But unfortunately net beans does not let me import that. It says which it is expecting a . Or when I insert. It goes in to that class and I cannot import that jar file into the project by import instruction. Is there a command in net beans which creates and object from jar file and then makes access to the functions and classes of the jar file? Would you please give the format of that instruction? If you know a better way to do this task I would be so happy if you share it with me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

上课铃就是安魂曲 2024-10-24 00:18:40

并不是 Netbeans 不允许您导入类,而是它找不到您想要导入的类。您应该首先将依赖项 jar 文件添加到 Netbeans 类路径中。

我假设您正在构建一个 Ant 项目。对于下游项目,在项目浏览器中右键单击该项目,然后从弹出菜单中选择“属性”菜单。从类别框中选择Libraries 节点。现在,您可以使用右侧的“添加 jar 文件”按钮将 jar 文件添加到项目中。

不过,我建议您看看使用 Maven 构建您的项目。您可以使用 xml 配置依赖项。话虽如此,您应该使用您最舒服的任何方式。

PS

  1. 这是“Netbeans”,而不是“Net beans”。
  2. 您可以使用 Netbeans 构建 jar 文件。您不必只是为了构建 jar 文件而一直使用 Eclipse。

It's not that Netbeans doesn't let you import the classes but it cannot find the classes you want to import. You should first add the dependency jar file to your Netbeans classpath.

I assume that you are building an Ant project. For a downstream project, right click on the project in project browser then choose Properties menu from popup menu. Select Libraries node from the catagories box. You can now add jar file to your project using the add jar file button on the right.

However, I recommend you to have a look at building your project using maven. You can configure the dependencies using xml. Having said that, you should use whatever you are the most comfortable with.

P.S.

  1. It's "Netbeans", not "Net beans".
  2. You can build a jar file using Netbeans. You don't have to go all the way to Eclipse just to build a jar file.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文