一个普通的java文件,编译后成为class文件
一个class文件或jar怎么得到java文件呢?
JD-GUI is a standalone graphical utility that displays Java source codes of
".class" files. You can browse the reconstructed source code with the JD-GUI
for instant access to methods and fields.
https://github.com/java-decompiler/jd-gui
> git clone https://github.com/java-decompiler/jd-gui.git
> cd jd-gui
> ./gradlew build
linux平台生成可执行文件在build/distributions/jd-gui-1.6.6.deb
安装后就可以使用了。
如何防止class的翻译呢?
https://github.com/core-lib/xjar
这个有springboot工程的插件,修改pom.xml文件
<!-- 设置 jitpack.io 仓库 -->
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://www.jitpack.io</url>
</repository>
</repositories>
<!-- 设置 jitpack.io 插件仓库 -->
<pluginRepositories>
<pluginRepository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</pluginRepository>
</pluginRepositories>
<!-- 设置 依赖 -->
<dependency>
<groupId>com.github.core-lib</groupId>
<artifactId>xjar</artifactId>
<version>4.0.1</version>
</dependency>
<!-- 添加 XJar Maven 插件 用于加密 -->
<plugin>
<groupId>com.github.core-lib</groupId>
<artifactId>xjar-maven-plugin</artifactId>
<version>4.0.1</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
<phase>package</phase>
<!-- 或使用
<phase>install</phase>
-->
<configuration>
<password>io.xjar</password>
<!-- optional
<algorithm/>
<keySize/>
<ivSize/>
<includes>
<include/>
</includes>
<excludes>
<exclude/>
</excludes>
<sourceDir/>
<sourceJar/>
<targetDir/>
<targetJar/>
-->
</configuration>
</execution>
</executions>
</plugin>
这样就可package时自动编译出jar和xjar
xjar就是加密过的,用go build target/xjar.go 就可编译出xjar引导文件
xjar java -jar XXX.xjar运行即可 自己用jar,发布出去xjar就保证了某种程度的保密
go是跨平台,下面是linux下的安装:
https://golang.google.cn/dl/
tar -C /usr/local -xzf go1.14.4.linux-amd64.tar.gz
$HOME/.profile:
export PATH=$PATH:/usr/local/go/bin
source $HOME/.profile.
go version