更改.jar文件没有源? [英] Change .jar file without the source?

查看:197
本文介绍了更改.jar文件没有源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于Java的TCP客户端与我的生产服务器对话,我正在重写。客户端有服务器的IP&端口硬编码。我想要做的是将客户端中的IP地址更改为127.0.0.1&我可以在我的开发箱上使用相同的端口号。这是擦,我没有所有的源代码,所以我不能只重新编译它。写这篇文章的人已经在这里工作了大约四年,虽然我有他的硬盘驱动器,但我找不到编译的循环返回客户端(即使我找到了部分源代码),甚至还没有找到生产客户端的源代码。我怀疑他在网络驱动器上编写了他的代码,并且在这几年中它已经丢失了。

I have a Java based TCP Client that talks to our production server, which I'm re-writing. The client has the server's IP & port hard coded. What I want to be able to do is change just the IP address in the client to 127.0.0.1 & I can use the same port number on my dev box. Here's the rub, I don't have all the source code, so I can't just recompile it. The guy who wrote it hasn't worked here for about four years and while I have his hard drive, I haven't been able to find a compiled loop back client (even though I found partial source code for it) or even all the source code for the production client. I suspect he wrote his code on a network drive and it's been lost through the intervening years.

我有什么方法可以反编译客户端并重新编译这个更改?十六进制或二进制编辑(我也没有技巧,我刚看到它完成了)?也许WinRAR因为我的理解是.jar文件只是压缩文件?或者,是否有某种方法可以从客户端捕获传出的TCP流量&将它重新路由到我的开发盒?我无法取下生产服务器进行测试,如果没有修改后的客户端,将难以确保我模拟生产服务器对客户端的响应。

Is there some way for me to decompile the client and recompile with that change? Hex or binary edit (I have no skill at either, I've just seen it done)? Maybe WinRAR since my understanding is that .jar files are just zipped files? Or, is there some way I could trap the outgoing TCP traffic from the client & re-route it to my dev box? I can't take down the production server to test, and without a modified client it's going to be difficult to ensure I'm emulating the production server responses to the client.

我发现了这篇SO文章: Decompile&从jar重新编译单个文件,但我不明白反汇编和&反编译,但我找到了那里提到的实用程序JD。

I found this SO article: Decompile & recompile single file from jar, however I don't understand the difference between disassembly & decompiling, but I have found the utility JD mentioned there.

推荐答案

你找到的java反编译器( http://java.decompiler.free.fr/ )将获取您编译的jar文件并创建java源文件。然后,您必须编辑源文件以进行所需的更改并重新编译。

The java decompiler you found (http://java.decompiler.free.fr/) will take the compiled jar file you have and create java source files. You will then have to edit the source files to make the changes you want and recompile.

我建议通过命令行配置主机和端口以避免此问题再次。

I would suggest making the host and port configurable via the command line to avoid this issue again.

这篇关于更改.jar文件没有源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆