Application runs faster in eclipse
I have an executable Java SE application in eclipse. I am downloading JPA to work in a normal Java 6 SE environment. Each query to various tables in the database does not take more than 100ms.
The problem is that when I export the executable jar and I say java -jar myapp.jar each request to the database takes about 9 seconds.
I don't understand why the application is faster when I run it from eclipse
source to share
In fact, every time I made a database query, I created an entity manager:
Persistence.createEntityManagerFactory( "mysqldb" );
To optimize the creation of the entity dispatcher, I use a singleton factory object like this:
private static EntityManagerFactory em = Persistence
.createEntityManagerFactory( "mysqldb" );
public static EntityManagerFactory getEmf()
{
return em;
}
this worked to improve the performance of the application outside of eclipse, but there is no performance change when I run it inside eclipse.
I'm not sure what the reason it worked better when the application was launched from eclipse, but this solution solved my problem for the moment.
source to share
I am not sure how to use the eclipse compiler. The eclipse ant script used is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project Server">
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required -->
<target name="create_run_jar">
<jar destfile="myapp.jar" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Main-Class" value="myapp.main.Main"/>
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="dir.../Myapp/build/classes"/>
<zipfileset excludes="META-INF/*.SF" src=
..exclude all libraries
</jar>
</target>
</project>
source to share