Can't open Java file, because of troubles with console. Please help me!

Hi! I have a problem. I need to open the .jar file but when I open it (I tried also double-click - open with - and Java Launcher and it wrote me that ''we can open the file, console is checking message error) please help

Thanks Mark

MacBook, macOS 10.15

Posted on Nov 3, 2020 4:02 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 3, 2020 8:41 AM

I would check the following. Open up terminal. Type in:


java -version


Did this output your current have version?


Also, type in:

echo $JAVA_HOME


Did this output a specific directory that's your Java home files location?


If those both give some specific output indicating the version and home directory comes back with some kind of non-empty response, you can use terminal to launch the jar file directly:


java -jar <yourfilename.jar>

Tip: If you aren't comfortable with terminal and navigating folder locations you can type:


java spacebar minus jar spacebar


...and then drag the icon for your JAR file into the terminal window and it will autocomplete path of the JAR file into the terminal window and you can just hit enter.


Generally though, and if this is too much for you, the easy solution is going to be to install or reinstall the Java JDK.

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html


Just select to install the macOS 64-bit version of the JDK (not the normal runtime JRE). You'll need to make a free Oracle website account. 99% of the time this is going to fix the problem.


The normal runtime version of Java (the "JRE") really stinks. It often doesn't set up Java home location properly. The JDK version (designed for developers) works 10x better even for a non-developer just trying to run a Jar file.

5 replies
Question marked as Top-ranking reply

Nov 3, 2020 8:41 AM in response to Maara04

I would check the following. Open up terminal. Type in:


java -version


Did this output your current have version?


Also, type in:

echo $JAVA_HOME


Did this output a specific directory that's your Java home files location?


If those both give some specific output indicating the version and home directory comes back with some kind of non-empty response, you can use terminal to launch the jar file directly:


java -jar <yourfilename.jar>

Tip: If you aren't comfortable with terminal and navigating folder locations you can type:


java spacebar minus jar spacebar


...and then drag the icon for your JAR file into the terminal window and it will autocomplete path of the JAR file into the terminal window and you can just hit enter.


Generally though, and if this is too much for you, the easy solution is going to be to install or reinstall the Java JDK.

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html


Just select to install the macOS 64-bit version of the JDK (not the normal runtime JRE). You'll need to make a free Oracle website account. 99% of the time this is going to fix the problem.


The normal runtime version of Java (the "JRE") really stinks. It often doesn't set up Java home location properly. The JDK version (designed for developers) works 10x better even for a non-developer just trying to run a Jar file.

Nov 9, 2020 10:13 AM in response to Mrokcratron

Hello, thanks very much for the reply.

I try everything you wrote:

  1. I typed the java version and the answer was:

java version "15.0.1" 2020-10-20

Java(TM) SE Runtime Environment (build 15.0.1+9-18)

Java HotSpot(TM) 64-Bit Server VM (build 15.0.1+9-18, mixed mode, sharing)


2.I typed echo $JAVA_HOME and answer was nothing:

didnt come nothing was there


3.I typed the code that starts the file - java -jar..... answer:

A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:564)

at cpw.mods.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:48)

at cpw.mods.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:17)

Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')

at net.minecraft.launchwrapper.Launch.<init>(Launch.java:33)

at net.minecraft.launchwrapper.Launch.main(Launch.java:27)

... 6 more


4.I tried to double-click on the file and the answer was:

"Checking errors message in console"


Than I tried to instal JDK and nothing new happened


Thanks for answers Mark

Nov 15, 2020 12:23 AM in response to Maara04

The issue is that you have the 1.15 of the Java run-time-only version (JRE), and 99.999999% chance you need the 1.8 version of Java. And specifically installing the 1.8 JDK (developer kit) version will fix any other issues, such as your java_home variable not being set (which is probably only the tip of the iceberg).


Install the Java 1.8 JDK (which is also referred to as Java 8) here:

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

Note: it requires you make a free oracle account before you can download.


Then switch your current "active" Java using this terminal command:

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)


Then do the "java -version" command again and it should indicate you're defaulting to the 1.8 (i.e. Java 8) version.


Then your minecraft server should launch fine (I assume that's what you're doing), or if it doesn't... then at least it's not a Java installed version issue.

Nov 17, 2020 10:43 PM in response to Mrokcratron

Hi I try it it was OK than I typ java version it was 1.8 than I tried double-click and i happens the same and after that i typ java version and I was 1.5 I don't understand it but ok. I tried once more switch the java to 1.8 successfully and than I typed java -jar and the server file name and the answer:

Unrecognized option: -jar/Users/mara/Desktop/FuturecraftServer/server.jar

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

Nov 18, 2020 9:11 AM in response to Maara04

It looks like you are just having a simple typo. You need to have a space after "-jar" before the path to your server.jar file.


So it would be as follows:


java -jar /Users/mara/Desktop/FuturecraftServer/server.jar


Or better yet would be to increase the RAM dedicated to the server.jar such as:


java -Xmx2G -jar /Users/mara/Desktop/FuturecraftServer/server.jar

(like if you wanted to set the amount of RAM to ramp up to 2 gigabytes, for example).


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Can't open Java file, because of troubles with console. Please help me!

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.