February 4, 2018

error: possible loss of precision using Math.pow in java

Problem : I compiled below code and got possible loss of precision error.
int a = Math.pow(3, 5);
System.out.println(a);

Solution : According to the java documentation, Math.pow() expects two doubles, and returns a double. When you pass two int values to this method, it converts an int to double. But when we assign the value to an int, it gives, possible loss of precision error while compiling the code. So you can cast method to an int or assign the returning value to double to resolve the error.

int a = (int)Math.pow (3,5);
or
double a = Math.pow (3,5);

July 31, 2017

Set or change default editor for JSP in Eclipse IDE

Problem : I want to set JSP Editor as a default editor in Eclipse IDE.

Solution : Follow below steps to change default editor to open JSP files in Eclipse IDE.

Step 1 : Start Eclipse IDE, click on Window then Preferences.
Step 2: In the pop-up window, click on "File Associations" inside "Editors" then click on *.jsp in "File types".

Step 3: After that you can see "Associated editors" as shown in below screenshot. Just select JSP Editor and click on Default button and OK button.

July 29, 2017

Error : Unable to acquire the state change lock for the module

Problem : Getting following error when starting eclipse IDE.

org.osgi.framework.BundleException: Unable to acquire the state change lock for the module: osgi.identity; osgi.identity="org.eclipse.core.runtime"; type="osgi.bundle"; version:Version="3.10.0.v20140318-2214"; singleton:="true" [id=83] STARTED [STARTED]
at org.eclipse.osgi.container.Module.lockStateChange(Module.java:329)
at org.eclipse.osgi.container.Module.start(Module.java:389)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)

Solution : Go to your eclipse IDE directory. Delete the lock files whose names starting with .fileTable from following location:
configuration/org.eclipse.osgi/.manager
Now restart the eclipse without rebooting the system.

Error: not able to start eclipse IDE

Problem : I was starting eclipse and it said an error has occurred, see ...\workspace\.metadata\.log.
I opened the log file which had following error log.

Caused by: org.osgi.framework.BundleException: Exception in org.eclipse.core.resources.ResourcesPlugin.start() of bundle org.eclipse.core.resources.
at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:792)
at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:721)
at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:936)
at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:319)
at org.eclipse.osgi.container.Module.doStart(Module.java:571)
at org.eclipse.osgi.container.Module.start(Module.java:439)
at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:454)
at org.eclipse.osgi.internal.hooks.EclipseLazyStarter.postFindLocalClass(EclipseLazyStarter.java:107)

Solution : Delete the snap file from this location  .metadata/.plugins/org.eclipse.core.resources/.snap in your eclipse workspace.

May 24, 2017

Oracle Database : System error 5 has occurred. Access is denied

Problem : I have installed Oracle 10g XE on Windows 8. When I try to start using the "Start Database" button, the command window pops up with the error :
C:\oraclexe\app\oracle\product\10.2.0\server\BIN>net start OracleXETNSListener
System error 5 has occurred.
Access is denied.
Solution : Right click on Start Database icon and Run as Administrator.


May 21, 2016

Bootstrap : Prevent or disable Modal pop up disappearing while outside click or pressing escape

Problem : I am working with Bootstrap Modal to display pop up window but whenever i click outside the modal or press escape button it goes disappear but i want to manually close it by clicking close button on modal pop up.

Solution : To disable on click set backdrop option as static and to prevent closing of the modal by esc button set keyboard option as false as shown in below given code.

1. If you are using javascript for displaying Modal.
$('#myModal').modal({backdrop: 'static', keyboard: false})  

2. If you are using data attributes on html or jsp.
<button data-backdrop="static" data-keyboard="false" data-target="#myModal" 
data-toggle="modal">  
Click Here for Modal  
</button>`  

Disclaimer

We shall not be liable for the improper or incomplete transmission of the information contained in this communication nor for any delay in its response or damage to your system. We do not guarantee that the integrity or security of this communication has been maintained or that this communication is free of viruses, interceptions or interferences. Anyone communicating with us by email accepts the risks involved and their consequences. We accept no liability for any damage caused by any virus transmitted by this site.