我们在eclipse中的项目大致显示以下文件夹:
application
- src
- JRE System Library [1.6]
- Referenced Libraries
- lib
- rsc
Run Code Online (Sandbox Code Playgroud)
在我们的项目中,我们想使用File> Export ...> Executable JAR
好吧,除了一些例外:如果我们想运行我们的application.jar,我们仍然需要将文件夹rsc /复制到application.jar的相同位置.
在rsc /中,我们有其他文件夹来分隔不同的部分.基本上,我们使用代码加载碎片(有点改变,但路径样式是正确的)
strUrl = "file:rsc/properties/Constants.properties";
url = new URL(strUrl);
ImageIcon icon = new ImageIcon(url);
Run Code Online (Sandbox Code Playgroud)
我可以右键单击rsc /> Build Path> Use as Source Folder.
但这不起作用,因为eclipse不会自动将rsc文件夹复制到bin/-folder中.然后我们不能再从终端运行它(没有打包到jar)
编辑:为什么eclipse无法正确处理?为什么"嵌套"输出文件夹有问题?在Build Path对话框的Source-tab中,我可以轻松添加rsc/-folder,输出文件夹设置为bin/rsc /,但它似乎无法放置嵌套文件夹...
编辑2:现在我已经能够创建一个xml文件来使用ant构建东西,并以某种方式设法将rsc文件夹包含在jar中.由于相同的错误仍然无法运行.我是否真的需要检查它们是否在JAR中的资源路径?JAR的内容现在如下:
META-INF/
META-INF/MANIFEST.MF
configurator/
controller/
editor/
gui/
logic/
networking/
rsc/
rsc/gamesettings/
rsc/levels/
rsc/pics/
rsc/properties/
util/
Run Code Online (Sandbox Code Playgroud)
但Java仍然讨厌我,并抛出java.io.FileNotFoundException: rsc/properties/Constants.properties大约100行的堆栈跟踪.
任何人都知道如何做到这一点?感谢和问候
我对Java一无所知.
有Java 6 steady state基准
http://shootout.alioth.debian.org/u64q/which-programming-languages-are-fastest.php
Run Code Online (Sandbox Code Playgroud)
这Java 6 steady state是所有其他Java中最快的.我搜索过,没有好结果
什么是Java 6 steady state?可以运行任何Java Web框架Java 6 steady state吗?
我的java版本是:
Java Plug-in 10.3.1.255使用JRE版本1.7.0_03-b05 Java HotSpot(TM)客户端VM
所以当我有版本6.x一切都很好,升级后我得到了这个:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: This function should be called while holding treeLock
at java.awt.Component.checkTreeLock(Component.java:1196)
at java.awt.Container.validateTree(Container.java:1682)
at pl.recorder.ScenarioWindow.showUploadPanel(PlayerWindow.java:721)
at pl.recorder.actions.UploadFilesAction.execute(DesignFilesAction.java:71)
at pl.recorder.actions.EndTestAction.actionPerformed(EndTestAction.java:91)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at … 我在Java 1.6中编写了一个webapp并在tomcat中运行它.虽然我没有做任何明确的线程,但我想知道Spring和Tomcat幕后发生了什么.我会使用StringBuilder而不是StringBuffer遇到任何问题吗?
我的API中有一个带有通用varargs参数的方法.我希望我的API是Java 6源代码和二进制兼容的,但如果Java 7 API消费者不会遭受不必要的"varargs"警告,那将会很好.
我能想到的一个技巧是将我自己的java.lang.SafeVarargs注释添加到我的API并将其与我的可交付成果一起发送.效果如下:
除了许可证问题,这是否可以保证有效?它似乎与javac一起使用.或者是否存在从JDK重新定义注释在呼叫站点具有不希望的副作用的配置?或者是否有另一种方法来解决这个Java 6/7互操作性问题?
一个相关的问题:
我注意到每个使用java 7的年轻垃圾收集平均比使用java 6的年轻垃圾收集要多10个毫秒.我正在使用1.6.0_31和1.7.0_21.配置没有改变,硬件和JVM参数都没有改变:
-server -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+TieredCompilation -XX:+AggressiveOpts -Xms1g -Xmx1g -XX:MaxNewSize=256m -XX:NewSize=256m
Run Code Online (Sandbox Code Playgroud)
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT 26176.0 26176.0 3531.6 0.0 209792.0 21648.8 786432.0 86777.6 49472.0 49350.1 82 1.830 0 0.000 1.
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT 26176.0 26176.0 0.0 1210.5 209792.0 95873.4 786432.0 65327.1 35968.0 35891.2 83 0.620 0 0.000 …
我正在使用JAXB生成XML.但是JAXB正在生成一个空标签.但我的客户想要单独的空标签.我知道两者都是平等但他不同意我的看法.请任何人建议解决方案.谢谢.
示例代码:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"currencyCode",
"discountValue",
"setPrice",
"spendLowerThreshold",
"spendUpperThreshold",
"discountApportionmentPercent",
"discountApportionmentValue"
})
@XmlRootElement(name = "countryData")
public class CountryData {
protected String currencyCode;
protected String discountValue = "";
protected String setPrice = "";
protected String spendLowerThreshold = "";
protected String spendUpperThreshold = "";
protected String discountApportionmentPercent = "";
protected String discountApportionmentValue = "";
// Setters and Gettres
}
Run Code Online (Sandbox Code Playgroud)
实际产量:
<currencyCode>GBP</currencyCode>
<discountValue/>
<setPrice/>
<spendLowerThreshold/>
<spendUpperThreshold/>
<discountApportionmentPercent>0.0</discountApportionmentPercent>
<discountApportionmentValue/>
Run Code Online (Sandbox Code Playgroud)
预期产出:
<currencyCode>GBP</currencyCode>
<discountValue></discountValue>
<setPrice></setPrice>
<spendLowerThreshold></spendLowerThreshold>
<spendUpperThreshold></spendUpperThreshold>
<discountApportionmentPercent>0.0</discountApportionmentPercent>
<discountApportionmentValue></discountApportionmentValue>
Run Code Online (Sandbox Code Playgroud)
编组代码:
try …Run Code Online (Sandbox Code Playgroud) 我是一个Java noob(但已经编程了25年以上,并且从第1天开始使用OO语言).
突然间我开始收到这个错误:
Your active platform is: JDK_1.6, but the corresponding property "platforms.JDK_1.6.home" is not found in the project's properties files.
Run Code Online (Sandbox Code Playgroud)
不确定是什么导致了这种情况,也不确定Java要求我做什么.我在NetBeans IDE中工作.我尝试做的最后一件事是向我的项目添加一些二进制(图像)资源.
我不想使用Tomcat,Jetty或Java EE 6容器来提供REST服务,而是使用内置的Web服务器.
当我尝试在App引擎中部署Java 6应用程序时.我得到了错误
Java 6 applications are prevented from being deployed to Google App Engine from any
version of the SDK, including older ones. If you need to continue to deploy Java 6
applications for compatibility reasons, you can request that your application be
whitelisted for Java 6 deployment by visiting link.
Run Code Online (Sandbox Code Playgroud)
然后我在项目设置中更改了java 1.7版.即使之后,app引擎部署也会抛出相同的错误.
如何解决这个问题.