Ask coding questions

← Back to all posts
Java isn't working, why?
Stanlyhalo (20)

I have made a window program before in another program, but it won't work, I hit run, and nothing happens, why? Repl:
https://repl.it/@Stanlyhalo/JAVA-testing-window

(Also opening it in another window is just a terminal).

NVM

Got it to work better, but if you check it out now, as you can see I am getting an error, saying something about line 11 on Main.java

Answered by Zeune (34) [earned 5 cycles]
View Answer
Commentshotnewtop
Zeune (34)

For Swing they implemented Java Swing as a language; it is separate from standard Java. Here you can program in a windowed environment.

Stanlyhalo (20)

@Zeune So it's already a window?

Zeune (34)

@Stanlyhalo So a few issues with the code, and once you get it setup you will run into an X11 Display error. Currently in your project you do not have a class called Game.java and you are trying to reference your constructor called Game.java inside of Main. That needs to be changed. Then, you will come into other errors for using the this reference object when there is nothing to.

Also, to answer your question about it is already a window. It's a window that is above the console it's built into the environment so you won't be able to click and drag it around. Resizing seems to be hit and miss as well. Honestly, I set my project up but, without being able to say obj.add(comp) I am struggling figuring out the project setup for Java Swing on repl.it

Stanlyhalo (20)

So I just realized, it only works in Windows, but how do I display it in the website.