这个问题与这里讨论的另一个主题有关:
Java字节码是否与不同版本的Java兼容?
但在这种情况下,想知道兼容性是在同一版本中保留,还是在不同的更新中保留.
例如,编译器在版本1.6.0_14上生成的字节码是否与1.6.0上的JVM兼容?代码运行愉快,但我不知道是否有任何意外可能出现的问题.
问候.
我是一个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中工作.我尝试做的最后一件事是向我的项目添加一些二进制(图像)资源.
在使用JDK 1.6编译时,是否可以选择构建在JRE 1.5上运行的Java代码?
PS:我是Java新手.
我不想使用Tomcat,Jetty或Java EE 6容器来提供REST服务,而是使用内置的Web服务器.
我有一个JTable扩展,自项目中的Java 1.3/1.4以来一直在使用,通过单击列提供列重新排序和排序等功能.我们正在升级到Java 1.6,新的JTable阻止旧的排序代码工作.将所有内容都安装到新的JTable API上会有一些广泛的返工.在那之前有没有办法在JTable中完全禁用这些添加?
编辑:在进一步调查之后,问题集中在这样一个事实:标题上的鼠标事件被1.6中的Swing吞噬,并且没有传递给表实现,即使它设置了自己的标题呈现.非常适合吹嘘的Java向后兼容性.
那么有没有办法让JTable 1.6停止?我无法做到.甚至覆盖表上的UI和表头也无济于事.
我们有一个在Java 6更新45中运行的JBoss应用程序服务器.我们遇到了我们最有可能自己介绍的OutOfMemoryErrors.我们想分析那些并想要创建堆转储.这失败,下面有例外.
谷歌搜索和搜索stackoverflow对我没有多大帮助,有没有人知道如何从这台机器获得堆转储?
谢谢!
马丁
例外是:
C:\>"d:\Program Files\Java\bin\"jmap -F "-dump:format=b,file=D:\heapdumps\20130620_085902_heap.dump" 1832
Attaching to process ID 1832, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.45-b01
Dumping heap to D:\heapdumps\20130620_085902_heap.dump ...
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.tools.jmap.JMap.runTool(JMap.java:179)
at sun.tools.jmap.JMap.main(JMap.java:110)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: Windbg Error: ReadVirtual failed!
at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.readBytesFromProcess0(Native Method)
at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.readBytesFromProcess(WindbgDebuggerLocal.java:485)
at sun.jvm.hotspot.debugger.DebuggerBase$Fetcher.fetchPage(DebuggerBase.java:76)
at sun.jvm.hotspot.debugger.PageCache.getPage(PageCache.java:178)
at sun.jvm.hotspot.debugger.PageCache.getInt(PageCache.java:96)
at sun.jvm.hotspot.debugger.DebuggerBase.readCInteger(DebuggerBase.java:355)
at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.readCompOopHandle(WindbgDebuggerLocal.java:332)
at sun.jvm.hotspot.debugger.windbg.WindbgAddress.getCompOopHandleAt(WindbgAddress.java:122)
at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:235)
at …Run Code Online (Sandbox Code Playgroud) 如何实例化HashMap以放置集合和对象?
//it's wrong
Map<String,?>params=new HashMap<String,? >
List<Person> lstperson=getPerson();
params.put("person",lstperson);
params.put("doc",objectDoc);
params.put("idSol",new Long(5));
service.method(params);
//method
public void method(Map<String, ?> params);
Run Code Online (Sandbox Code Playgroud) 我在一家公司工作,不会在我们的服务器上从JRE 6升级到JRE 7.我已经使用Jetty 9成功开发了一些适用于JRE 7的代码.但是,我无法在公司服务器上运行此代码.我想知道是否有人在这里知道在JRE 6上运行Jetty 9的方法.我特别需要Jetty 9中的HTTPConfiguration类.
我能想到的唯一潜在的事情就是下载Jetty,将它设置为1.6合规性并从中开始工作.我真的希望(在黑暗中拍摄)有人有更好的主意.
当我尝试在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引擎部署也会抛出相同的错误.
如何解决这个问题.
在我的服务中,某个月的最后一天有哪些功能?
DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
Date date = format.parse(stringDate);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, 1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.add(Calendar.DATE, -1);
Date lastDayOfMonth = calendar.getTime();
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return sdf.format(lastDayOfMonth);
Run Code Online (Sandbox Code Playgroud)
所以,这种方法在其他地方正确使用,但在美国最后一天总是29(最后一天 - 1)
stringDate是格式为"yyyy-MM-dd"的日期