0

I am baffled at this issue. I just wanted to create a JFrame for testing, this is the only class:

import javax.swing.*;

public class TextPaneTest extends JFrame {

    public TextPaneTest(){
        setTitle("Test");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
        setSize(200, 200);
        setVisible(true);
    }

    public static void main(String[] args){
        new TextPaneTest();
    }
}

I am using IntelliJ IDEA 2019.2.4 as my IDE.

The result is a small white JFrame opens up for 2 seconds and closes. You can't move or resize the window and the cursor remains in "wait" mode when you hover the frame.

This is my project structure:

project structure

And this is my run configuration:

run configuration

There is no error message or exception. All the console shows is:

Process finished with exit code -1073740771 (0xC000041D)

I've already done a clean reinstall of both the JRE and JDK

This is my current java -version:

java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)

My OS is Windows 10 Home Single Language 1903

I don't know what else to add. I've been using Java for the past 5 years as a hobbyist and I've never came across an issue so fundamental as this.

Update

  • Tried instantiating TextPaneTest() using SwingUtilities.invokeLater()
  • Tried building the JAR and running from a command window

None has worked so far. Exactly the same behaviour.

Update 2

Fixed it by switching the 64 bit JRE for the 32 one. Is this a bug with the 64 one or could there be an underlying problem?

  • Can you run it from the command line (export the project and run it from the command line) - the intent is to try and figure out it's an issue with Java or your code or the IDE – MadProgrammer Nov 24 '19 at 23:17
  • I think this is a Java issue, specifically in the context of Windows. Check out this [old question](https://stackoverflow.com/questions/29031842/application-exiting-with-an-exit-code-of-1073740771). If you search the web, you only get a few hits, against Eclipse, IntelliJ and no IDE at all, so it's unlikely to be IntelliJ's fault. EDIT: I just ran this code on Win 10 Pro, 1909, from console with no issue. – MarsAtomic Nov 24 '19 at 23:21

1 Answers1

2

I cannot reproduce the issue on my macintosh, but I notice you are doing everything on the main thread. You shouldn't do that. Make sure all events happen on the Event Dispatch Thread. For example,

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            new TextPaneTest();
        }
    });
}
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
  • 1
    While I would also recommend this, since the frame won't attach to the Event Thread until it's realised on the screen (ie made visible), this is unlikely to be the cause of the issue ... still "best practices" suggestion – MadProgrammer Nov 24 '19 at 23:16
  • The first test I made was using the dispatch thread, I changed it in case it had something to do. But yeah, behaviour doesn't change. – Milanesa-chan Nov 25 '19 at 00:18
  • @Milanesa-chan Have you tried OpenJDK? 232-b09 is out, I see you're using 231-b11. – Elliott Frisch Nov 25 '19 at 00:29
  • As stated in my edit, the app works as intended with the 32-bit alternative of the same JRE. (tested building with 64-bit JDK). – Milanesa-chan Nov 26 '19 at 20:20
  • 1
    @Milanesa-chan Then it's a 64-bit JRE bug. – Elliott Frisch Nov 27 '19 at 01:46