Java“常量字符串太长"编译错误.仅在使用 Ant 时发生,在使用 Eclipse 时不发生 [英] Java "constant string too long" compile error. Only happens using Ant, not when using Eclipse
问题描述
我在一个类中有一些非常长的字符串用于初始化用户信息.当我在 Eclipse 中编译时,我没有收到任何错误或警告,生成的 .jar 运行良好.
I have a few really long strings in one class for initializing user information. When I compile in Eclipse, I don't get any errors or warnings, and the resulting .jar runs fine.
最近,我决定创建一个 ant 构建文件来使用.每当我用 ant 编译同一个类时,都会出现常量字符串太长"编译错误.我尝试了多种方法来在 ant 中设置 java 编译器可执行文件,以确保我使用的版本与 Eclipse 中的版本完全相同.
Recently, I decided to create an ant build file to use. Whenever I compile the same class with ant, I get the "constant string too long" compile error. I've tried a number of ways to set the java compiler executable in ant to make sure that I'm using the exact same version as in Eclipse.
我宁愿弄清楚如何在 Ant 的 Eclipse 中获得相同的成功编译,而不是尝试重新编写代码以动态连接字符串.
I'd rather figure out how to get the same successful compile I get in Eclipse in Ant than try to rework the code to dynamically concatenate the strings.
推荐答案
有人试图向您发送消息 :-) 在您花时间摆弄编译器版本的时候,您可以从文本文件中加载数据 -这可能是它所属的地方.
Someone is trying to send you a message :-) In the time you've spend fiddling with compiler versions you could have loaded the data from a text file - which is probably where it belongs.
退房:
这篇关于Java“常量字符串太长"编译错误.仅在使用 Ant 时发生,在使用 Eclipse 时不发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!