Author Archive: Johny

HibernateUtil class initializing error when converting ant project to maven

Im at the middle of the Converting ant project to maven and i have below jar files in my lib folder activation.jar antlr-2.7.6.jar asm-3.3.jar asm-commons-3.3.jar asm-tree-3.3.jar barchartcustomizer.jar c3p0-0.9.0.jar cglib-2.2.3.jar commons-beanutils-core-1.8.0.jar commons-collections-3.2.jar commons-digester-2.1.jar commons-fileupload-1.3.1.jar commons-io-2.2.jar commons-lang3-3.1.jar commons-lang-2.4.jar commons-logging-1.1.3.jar dom4j-1.6.1.jar ecj-4.3.1.jar ejb3-persistence.jar freemarker-2.3.19.jar hibernate3.jar hibernate-c3p0-4.3.5.Final.jar hibernate-core.jar hibernate-jpa-2.0-api-1.0.1.Final.jar hibernate-validator-annotation-processor-5.1.1.Final.jar itext-2.1.7.js2.jar jasperreports-5.6.1.jar java-json.jar javassist-3.11.0.GA.jar javax.annotation.jar javax.ejb.jar javax.jms.jar javax.mail.jarjavax.mail.jar javax.resource.jar javax.servlet.jar javax.servlet.jsp.jar javax.servlet.jsp.jstl.jar…
Read more

If shared preferences does not contain

SharedPreferences mPrefs = getSharedPreferences(“IDvalue”,0); if(mPrefs.contains(“DATE”)) { //do something }else { mPrefs.edit().putString(“DATE”, currentdate); mPrefs.edit().commit(); Toast.makeText(this, “changed”, Toast.LENGTH_SHORT).show(); } What i want the code to do is run the first time and show the toast but the second time it is run not show it and run the code inside the first parameters. But as it is now the code just runs…
Read more

Create replicated cache at runtime

I want to create replicated cache at runtime without configuration.xml When I use next configuration for cache: <cache name=”pcid” maxEntriesLocalHeap=”10000″ maxElementsOnDisk=”0″ overflowToDisk=”false” eternal=”false” timeToIdleSeconds=”600″ memoryStoreEvictionPolicy=”LRU”> <cacheEventListenerFactory class=”net.sf.ehcache.distribution.RMICacheReplicatorFactory” properties=”replicateAsynchronously=false”/> <!– RMI Cache bootstrap –> <bootstrapCacheLoaderFactory class=”net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory” properties=”bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000″ propertySeparator=”,” /> </cache> all work perfectly. If I create cache manually: RMICacheReplicatorFactory factory = new RMICacheReplicatorFactory(); Properties properties = new Properties(); properties.put(“replicateAsynchronously”,”false”); CacheEventListener…
Read more

Why should SwingUtils.invokeAndWait() method be called outside an EDT thread?

private void init() { JFrame jfr = new JFrame(); jfr.setSize(500, 500); jfr.setVisible(true); jfr.setTitle(“Test”); JButton jb = new JButton(“Ok”); jfr.add(jb); jb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { System.out.println(“hello”); } }); } catch (Exception e1) { e1.printStackTrace(); } } }); First Question :(While using InvokeAndWait) Why is it implemented in…
Read more

Retrofit: pass custom arraylist to Retrofit in post Request

I want to pass a custom arraylist to retrofit and my json format is { “ProjectID”: 1, “Iteration”: [ { “IterationName”: “Wits”, “StartDate”: “yyyy-MM-dd HH:mm:ss.SSSZ”, “ReleaseDate”: “yyyy-MM-dd HH:mm:ss.SSSZ”, “Status”: “Completed”, “Type”: “Internal” }, { “IterationName”: “Wits”, “StartDate”: “yyyy-MM-dd HH:mm:ss.SSSZ”, “ReleaseDate”: “yyyy-MM-dd HH:mm:ss.SSSZ”, “Status”: “Running”, “Type”: “Client” } ] } I have searched online and i got only how to pass…
Read more

Making WIFI application in Java, and Making network application in java which uses WIFI as source of Internet is same thing?

Some where searching on stackoverflow, it came to my knowledge that Java does not support making wifi application (for example an application that can share file using WiFI) but Java support network application based on TCP using socket or serversocket class. So Can I make a java application that can communicate through WIFI internet? Source: java

iOS CoreImage Instant photo effect in Android, how to make it?

I’m a newbie with Android and I would like to filter an image with Instant photo effect on Android, like the CIPhotoEffectInstant that’s available for iOS: I’ve found many tutorials about grayscaling, gamma correction, sepia, etc, but nothing about the most used photo filter, Instant. Any idea about how to build it in .java? Thanks! Source: java

How to handle race conditions in Web Service?

I implemented a Web Service with Java Servlets. I got the following setup: There is a database which handles ‘job’-entries. Each job has a status like ‘executing’ or ‘in queue’ or ‘finished’. If a user starts a new job, there is made an entry in the database with a job and the status ‘in queue’. The job should only be…
Read more