简体   繁体   English

停止对可运行 Jar 的外部库访问

[英]Stop external library access to runnable Jar

So I have a Java application I will be releasing to one of my communities for a price.所以我有一个 Java 应用程序,我将有偿发布给我的一个社区。 The app is just about complete and ready to be obfuscated but the problem is;该应用程序即将完成并准备进行混淆,但问题是;

I found that when I add the Jar to another project in Eclipse you can instantiate classes externally and use my program as an external library to make scripts outside of my program.我发现当我将 Jar 添加到 Eclipse 中的另一个项目时,您可以在外部实例化类并将我的程序用作外部库以在我的程序之外制作脚本。 This is not what I'm wanting to achieve here... I'm self taught so I have grey areas of knowledge as I haven't learned formally, but I'm pretty experienced in Java still... I've tried googling it and nothings coming up, maybe I'm not phrasing it correctly.这不是我想要在这里实现的目标......我是自学的,所以我有一些灰色的知识领域,因为我还没有正式学习过,但我在 Java 方面仍然很有经验......我试过了谷歌搜索它并没有出现,也许我的措辞不正确。 But if I could get some help it would be appreciated.但如果我能得到一些帮助,我将不胜感激。

Here is my structure of my packages:这是我的包裹结构:

src.com
Contains main class
src.com.scripts
Contains Abstract Script class
src.com.scripts.impl
Contains the actual scripts that extend the abstract Script class

What I've tried doing:我尝试做的事情:

I removed the public Identifier from the Abstract Script class but then it isn't visible to the main class to call it from as it is in the package before.我从抽象脚本类中删除了公共标识符,但是主类看不到它,因为它在之前的包中调用它。 So how can I go about this when my project is sorted in packages and they all need to access eachother?那么当我的项目按包排序并且它们都需要相互访问时,我该如何处理呢?

There is no solution.没有解决办法。

If people want to reverse engineer your code, they will.如果人们想对您的代码进行逆向工程,他们会这样做。 There is nothing you can do to change that.你无法改变这一点。 public / private are essentially meaningless beyond helping you write good portable code.除了帮助您编写良好的可移植代码之外, public / private基本上没有意义。

That being said, Java is generally much easier to reverse engineer and make bindings to than other languages.话虽如此,Java 通常比其他语言更容易进行逆向工程和绑定。 Java doesn't inline functions and unless told otherwise, it will even leave all of your class and method names intact. Java 不内联函数,除非另有说明,否则它甚至会完整保留所有类和方法名称。 If you had used a language like C, the optimized binary would be a bigger pain to work with, but the result would still be the same.如果您使用过像 C 这样的语言,那么使用优化的二进制文件会更麻烦,但结果仍然相同。

Just obfuscate the jar and call it a day.只需混淆罐子并收工。 Manually changing how you write your code is more harmful to you than it is to them.手动更改您编写代码的方式对您的危害比对他们的危害更大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM