javarevisited

javarevisited


How to escape text when pasting as String literal in Eclipse Java editor

Posted: 21 Dec 2012 09:22 PM PST


Whenever you paste String in Eclipse which contains escape characters,  to store in a String variable or just as String literal it will ask to manually escape special characters like single quotes, double quotes, forward slash etc. This problem is more prominent when you are pasting large chunk of data which contains escape characters like a whole HTML or XML file,  which contains lots of single quotes e.g. '' and double quotes "" along with forward slash on closing tags. It's very hard to manually escape all those characters and its pretty annoying as well. While writing JUnit test for XML documents, parsing and processing I prefer to have whole XML file as String in Unit test, which pointed me to look for that feature in Eclipse. As I said earlier in my post Top 30 Eclipse keyboard shortcuts, I always look to find new shortcut and settings in Eclipse which help to automate repetitive task. Thankfully Eclipse has one setting which automatically escapes text as soon as you paste it. This is even more useful if you prefer to copy file path and just paste it, Since windows uses forward slash it automatically escape that instead of you going manually and escaping them. By default this setting is disabled in Eclipse IDE and you need to enable it.
Read more »

Invalid initial and maximum heap size in JVM - How to fix

Posted: 21 Dec 2012 06:17 AM PST

I was getting "Invalid initial heap size: -Xms=1024M" while starting JVM and even after changing maximum heap size from 1024 to 512M it keep crashing by telling "Invalid initial heap size: -Xms=512m , Could not create the Java virtual machine" , I check for almost everything starting form checking how much physical memory my machine has to any typo in JVM parameters, only to find out that instead of M, I had put MB there. Java accepts both small case and capital case for Kilo, Mega and Gigs. you can use m or M, g or G etc but never used MB, GB or KB.  Similar problem can occur with maximum heap size specified by -Xmx. Also from Java 6 update 18 there is change on default heap size in JVM.  
Read more »


Post a Comment