java-5

Convert java 5 code using generics to code that can run on a J2ME device?

偶尔善良 提交于 2019-12-06 09:03:54
问题 Are there any solutions or tools that transform java 5 code that uses all the new java 5 features(generics, autoboxing, varargs, static imports) into code that can run on a J2ME device? I am particularly interested in handling generics - the other features are nice to have but not mandatory. I need source code as the result of this conversion as this will be compiled using a custom compiler. (I cannot use bytecode manipulation(ala retroweaver)) 回答1: Compiling with the regular javac and

Java 1.5 JOptionPane paint bug when using panel message/workaround?

自作多情 提交于 2019-12-05 17:54:41
I have a JOptionPane with a custom message panel in it, in an application targeted for Java 1.5. The panel contains, among other things, a JTextField. Every 20 invocations or so, nothing in the dialog gets painted (not even the OK/Cancel buttons). If I drag the dialog off the screen and back again to force a repaint, the components are visible as expected, and apart from the painting problem, the components respond fine. Here is the smallest example I could get to exhibit this bug: public class BugTest { public static void main(String args[]) { SwingUtilities.invokeLater(new Runnable() {

Convert java 5 code using generics to code that can run on a J2ME device?

。_饼干妹妹 提交于 2019-12-04 13:01:57
Are there any solutions or tools that transform java 5 code that uses all the new java 5 features(generics, autoboxing, varargs, static imports) into code that can run on a J2ME device? I am particularly interested in handling generics - the other features are nice to have but not mandatory. I need source code as the result of this conversion as this will be compiled using a custom compiler. (I cannot use bytecode manipulation(ala retroweaver)) Compiling with the regular javac and targeting an older JVM will give you proper bytecode for generics at least. If you really need source it's

Java Quickly check for network connection

谁说我不能喝 提交于 2019-12-04 02:41:23
My issue is fairly straightforward. My program requires immediate notification if a network connection is lost. I'm using Java 5, so I'm unable to use the very handy features of NetworkInterface . Currently I have two different methods of checking for a network connection: (try..catches removed) Method One: URL url = new URL("http://www.google.com"); HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection(); // trying to retrieve data from the source. If offline, this line will fail: Object objData = urlConnect.getContent(); return true; Method 2: Socket socket = new Socket("www

Pop-up window in Java Swing

一曲冷凌霜 提交于 2019-12-04 01:09:25
问题 Can someone suggest me how to implement a pop-up window in Java Swing. I want the pop-up window to be a modal window (user cannot return to the main window when the pop-up is open). I tried doing it using JDialog but it allows only one widget for user input to be in it whereas I need multiple widgets. I may be wrong here but this is what I was able to do. Appreciate your help. 回答1: Use a JDialog. There is no restiction on what you can add, you can add whatever you want to a JDialog (exactly

What is the easiest way to iterate over all the key/value pairs of a java.util.Map in Java 5 and higher?

烈酒焚心 提交于 2019-12-03 09:24:11
What is the easiest way to iterate over all the key/value pairs of a java.util.Map in Java 5 and higher? Assuming K is your key type and V is your value type: for (Map.Entry<K,V> entry : map.entrySet()) { K key = entry.getKey(); V value = entry.getValue(); // do stuff } 来源: https://stackoverflow.com/questions/585654/what-is-the-easiest-way-to-iterate-over-all-the-key-value-pairs-of-a-java-util-m

send a mail from java5 and java6

孤人 提交于 2019-12-01 13:10:34
I know similar questions have been asked many times befor, but I think this one slitly different :) I'm writing a maven report plugin which will send emails to a list of users. I now have the problem, that the code seems to be working fine when I run it with java5, but failes with java6. Actualy the plugin is writen in Groovy and uses the commons-email utilities to send a html message: HtmlEmail email = new HtmlEmail(); email.setHostName(mailhost); email.setSmtpPort(mailport); email.setFrom(args.from); email.addTo(args.receiver); email.setSubject(args.subject); email.setHtmlMsg(args

send a mail from java5 and java6

陌路散爱 提交于 2019-12-01 12:20:24
问题 I know similar questions have been asked many times befor, but I think this one slitly different :) I'm writing a maven report plugin which will send emails to a list of users. I now have the problem, that the code seems to be working fine when I run it with java5, but failes with java6. Actualy the plugin is writen in Groovy and uses the commons-email utilities to send a html message: HtmlEmail email = new HtmlEmail(); email.setHostName(mailhost); email.setSmtpPort(mailport); email.setFrom

Java memory dump issue

无人久伴 提交于 2019-12-01 11:29:12
问题 I have tried to create a memory dump using with below code **/usr/lib/jvm/j2sdk1.5-sun/bin/jmap -heap 10699** but i got below mentioned error, anyone can help to me Attaching to process ID 10699, please wait... Error attaching to process: sun.jvm.hotspot.debugger.DebuggerException: Can't attach to the process I'm using java 5 回答1: To be proactive, I'll assume you're running ubuntu. In that case, type the following: echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope If you're not running

IMAP access to mail office 365 with javamail

≡放荡痞女 提交于 2019-12-01 06:56:19
I'm trying to read the emails in a folder of an email account Office365 using JavaMail 1.4 api. My code is: public static void main(String argv[]) throws Exception { // Get a Properties object Properties props = System.getProperties(); // Get a Session object Session session = Session.getInstance(props, null); // Get a Store object Store store = null; Folder rf = null; if (CUR_MAIL_PROTOCOL != null) store = session.getStore("imap"); // Connect if (CUR_MAIL_HOST != null || CUR_MAIL_LOGIN != null || CUR_MAIL_PWD != null) store.connect("outlook.office365.com", 993, "**MYEMAIL**", "**MYPASS**");