Java Application don't close after running my Code

how to enable java on chrome
java control panel
java not working windows 10
how to enable java in chrome windows 10
java jdk
java 64-bit
java setup
java environment

i am trying Hibernate 4 in Netbeans 8, the problem is that after the the committed is done the application still running.

Here is the code

public class TestHibernateAnotation {


/**
 * @param args the command line arguments
 */
public static void main(String[] args) {

Users user = new Users();
 Users user2 = new Users();

user2.setUser_name("Djalil");
user.setUser_name("Daniel");

Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
session.save(user);
session.save(user2);
session.getTransaction().commit();
session.close();
System.out.print("End of code");

}
}

My Hibernate Config

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate      Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-   configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/SalesTest</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<mapping class="testhibernateanotation.NewClass"/>
<mapping class="testhibernateanotation.Users"/>

any Idea about this issue thank you,


You need to explicitly destroy the service registry after session.close();. This seems to be a bug in newer hibernate versions. So basically your code that cleans up at the end should look like :

sessionFactory.close();
StandardServiceRegistryBuilder.destroy(sessionFactory.getSessionFactoryOptions().getServiceRegistry());

Plug: I had posted an example here - including this issue.

How do I enable Java through the Control Panel?, The Java content in the browser is disabled in the Java Control Panel. If Java is already installed Click Apply and then OK to confirm the changes. Restart the  Java software for your computer, or the Java Runtime Environment, is also referred to as the Java Runtime, Runtime Environment, Runtime, JRE, Java Virtual Machine, Virtual Machine, Java VM, JVM, VM, Java plug-in, Java plugin, Java add-on or Java download.


I found the solution (in an other post), it would be adding this to your config files:

<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">100</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.max_statements">10</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.timeout">100</property>

They said that it is bug in hibernate 4

Java Runtime Environment/How to run java applications , Some Java applications (for example, mkgmap.jar) cannot run without terminals. It's not so hard even if you don't have any experience of command lines. Java+You, Download Today!. Java Download » What is Java? » Do I have Java? » Need Help? » Uninstall About Java


you will have to close the SessionFactory object [ HibernateUtil.getSessionFactory().openSession() ]

The SessionFactory is a heavyweight object; it is usually created during application start up and kept for later use.The SessionFactory is a thread safe object and used by all the threads of an application. We can create one SessionFactory implementation per database in any application. If your application is referring to multiple databases, then you need to create one SessionFactory per database.

its how hibernate SessionFactory was designed.

https://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/SessionFactory.html

Create your first Java application - Help, Don't create a project from the template. In this tutorial, we're going to do everything from scratch, so click Next. Name the project, for example:  It is recommended you update Java before allowing the app to run. Click Update and download the latest Java version. If you don't trust the site or prompt, you can visit the java.com web site to get the latest version. The out-of-date ActiveX control blocking applies to: Windows 7 SP1 Internet Explorer 8 through Internet Explorer 11.


Migrating Java applications to Quarkus: Lessons learned, when migrating a Java application to Quarkus and how to resolve them. If you don't know what Quarkus is, then I recommend reading this  Run an application blocked by Java security in Windows If you’re running into Java security alerts, there are a few things you can do to work around them. It can be as simple as updating everything to adding a website to the exceptions list, depending on what you’re doing to trigger the alert.


Packaging and Distributing Java Desktop Applications, Calling the application from a script file. Using Java Web Start. Contents. Content on this page applies to NetBeans IDE 8.0. Creating Executable JAR File. Dockerize your Java Application A Dockerfile is a fundamental building block used when dockerizing your Java applications, and it is how you can create a Docker image that can be used to create the containers you need for automatic builds.


Java Application don't close after running my Code, You need to explicitly destroy the service registry after session.close(); . This seems to be a bug in newer hibernate versions. So basically your  I am new to NetBeans and I can't create a "Java Application" project, like shown in all tutorials. I can only create a Java Free-Form Project, but this requires a build script, which I don't have e