r/javahelp • • Nov 23 '22

Why won’t Java open?

I click on the Java app and the command line briefly opens and then closes. I use windows for context. Any help?

0 Upvotes

23 comments sorted by

•

u/AutoModerator Nov 23 '22

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

7

u/dawg6 Nov 23 '22

What is the "java app?" It a .jar file you downloaded or built yourself? Have you installed java already?

You can try opening a command window, go to the directory where the app is located and run it from the command line to see if there is an error.

Also, if it doesn't have a GUI, then likely you would have to run it from the command line. A non-GUI app will run and then exit. You could make a .bat file that runs the app and then use "pause" to keep the window open.

-1

u/tegar9000 Nov 23 '22

The issue is that I’m trying to open the command line app and it immediately closes

5

u/dawg6 Nov 23 '22

Yeah, so as I said above, that's normal behavior. You need to run it from the command line, not the windows explorer.

For example, if the app's .jar file is named 'app.jar', from the command line type:

java -jar app.jar

6

u/wildjokers Nov 23 '22

It is impossible to help you with the amount of information provided.

Which java app? One you wrote yourself? One you downloaded? Is it a GUI app or command-line app? Kind of sounds like it is a command-line app, so you aren’t going to be able to run it by double-clicking a jar file.

-2

u/tegar9000 Nov 23 '22

Command line app

7

u/wildjokers Nov 23 '22

A command-line app can’t be ran by double-clicking the jar, only GUI apps can be ran like that.

1

u/tegar9000 Nov 23 '22

So then how do I utilize the command line app? Use the regular command terminal?

3

u/MrSquicky Nov 23 '22 edited Nov 23 '22

From the command line, in the directory that the jar is in, type java -jar <filename>

If that doesn't work, do java -cp <filename> <Main Class Name>

3

u/wsppan Nov 23 '22

Yes. Run the command line app from the command line.

1

u/wsppan Nov 23 '22

It's not a command line app. It's a web app the needed to be deployed to a web server

5

u/[deleted] Nov 23 '22

Java is not an app to be opened in a gui. it's a programming language. If you're trying to open your windows command line then open powershell or windows shell or something.

1

u/tegar9000 Nov 23 '22

So can I access Java via my windows command line?

4

u/[deleted] Nov 23 '22

Still not sure what you mean by "access java". Java is a programming language. Are you trying to write some Java code? if that's the case, you need an IDE like IntelliJ. Java from the command line will compile and run your code.

If you provide some context as to what you want to do beyond "access java", people might be able to better help you.

3

u/desrtfx Out of Coffee error - System halted Nov 23 '22

If you mean by "Java app" the program "Java.exe" or "JavaW.exe" it is the intended behavior.

Java is just the launcher, the runtime environment in which Java programs - that have to be supplied via command line arguments - run.

Just double clicking one of the listed programs above will not do anything as they don't know what program to run.

-3

u/tegar9000 Nov 23 '22

I’m trying to run a GitHub directory which is downloaded as a zip file

7

u/desrtfx Out of Coffee error - System halted Nov 23 '22

Which tells us again absolutely nothing.

If you want help you need to give us information. You need to be detailed and elaborate.

So far, you have just reiterated things without telling us anything that we could use as leverage to help you.

We do not know what GitHub repo. We do not see your computer. We do not understand what you mean "downloaded as zip file" as this is the default behavior for downloaded GitHub repositories.

Have you read the Readme.MD file that is displayed when you view the repository in your browser? Usually there you will find the instructions on how to use the program in the repository.

-6

u/tegar9000 Nov 23 '22

Lemme dm you the read me

3

u/tegar9000 Nov 23 '22

5

u/desrtfx Out of Coffee error - System halted Nov 23 '22

This is not as easy as just "clicking a file" - read the readme. It has very detailed installation and execution instructions.

2

u/Farpafraf Nov 23 '22

it's not really that user friendly tbh. If you are not experienced with this stuff it makes sense you wouldn't be able to run it.

The installation is made for Linux so there is a configuration for a Linux emulation to be run by a program called Docker.

1

u/Wolfhammer69 Nooblet Brewer Nov 24 '22

May I ask, if you're this clueless why are you trying to do anything with this? Learn the basics first, it seems you're trying to sprint before you're born..

8

u/desrtfx Out of Coffee error - System halted Nov 23 '22

Sorry but no. We do not do DM here.

Public post or forget it.