Environment: Windows 11
Problem: cannot open .jar file(the MARS assembly language simulator)
Hello, I am currently trying to install the MARS assembly language simulator. It is a .jar file so I downloaded java to open it. However, I still can't open the file even with java downloaded.
I checked if java was installed using my cmd:
Command prompt showing java successfully installed
I tried double-clicking it did not work. So I right-clicked it to open with other apps. But I did not see java in the given options.
Cannot find the java option to open the file
Thank you so much for helping!
Use your prompt
CD into the directory with the jar
then execute
java -jar Mars.jar
...any more troubles , open file properties tab with right click on the jar and check permissions to execute the file.
Installing Java usually means installing a JVM, which is a Java Virtual Machine. You won't be able to launch files from a Windows context menu like this, because "Java" is not a program that opens files.
Instead you need to:
Either a terminal and call javaw.exe with the parameters -jar and your .jar-file. E.g.:
C:\your\java\binaries\javaw.exe -jar -SomeJarFile.jar
Or add the Java installation to your environment variables, then you can call javaw.exe without providing some specific path
Related
So, I have a program in a .exe file that needs Java 8 to run. I have Java 16 installed. I tried installing Java 8 with a Java installer that came bundled with the program but it is still run with Java 16. I have seen solutions that solve that problem but only with .jar files (using Java.exe CLI to launch the file with different Java path). I have lots of apps that run on newer Java versions so I can't uninstall Java 16.
The program is here, it's all in Ukrainian but there is Google Translate (press the red button to download zip file, clear on VirusTotal except some antivirus flagging a runtime packer, Інсталяція Polynom.txt is the README)
UPDATE 1: in reply to a comment in an answer, the contents of the cmd file:
set JAVA_HOME=C:\Program Files (x86)\Java\jre1.8.0_291
set PATH="%JAVA_HOME%\bin;%PATH%"
D:\Distributive\Polynom\Polynom.exe
So, you need to set JAVA_HOME (location where you installed JAVA 8, must have a directory bin and lib), and optionally add that to your PATH.
Open CMD.EXE
set JAVA_HOME=C:\path\to\Java
set PATH="%JAVA_HOME%\bin;%PATH%"
In the above file, java.exe is in C:\path\to\Java\bin\java.exe.
Then run the program from CMD.EXE
If that works, create a CMD file containing the above text - when you want to start the program, start the CMD file.
notepad c:\Users\jdoe\myprogram.bat
Copy the above two set lines into that file followed by the full path to the program you want to run. The file would look something like this:
set JAVA_HOME=C:\path\to\Java
set PATH="%JAVA_HOME%\bin;%PATH%"
C:\Users\jdoe\MyProgram.exe
Tip: If you want the icon of the program, create a shortcut of the CMD file
Right-click the CMD file, click New > Shortcut
Right-click the shortcut, click Properties, click Change icon
Navigate to the EXE file and select the icon you want
I have created a java program (in Eclipse). I have successfully compiled it to a .jar file which I can run on windows without any problems. I want to give this program to a friend who has a MacOSX. So my aim is to:
Create a file which can be run on MacOSX
The twist is that I have to configure it on my Windows computer since I don't have access to a Mac. Any advice would be of great help!
I am not sure what you are referring as "create a file which can be run on macOSX"
If you want to run on any OS you just need a JRE on that particular system without it you cant run. It will provide a runtime environment to run a jar file. Then use below command to run the jar.
java -jar Myjar_file.jar
First thing I installed Java jdk and jre
Then I installed a file called ssh_rd_rev04b.jar
I tried to open the jar file but it didn't run
I double clicked it,
I made a .bat file and typed java -jar filename didn't work too, tried other things but didn't work as well .
Please help .
Okay so I have been coding a game for a while now and I am hoping to release its alpha just one problem. I don't know how to export it and run it. Please note that all my code works fine. So when I export it I export it as a Runnable jar file once I do so I set it and have tried both exporting it as .jar and .exe. Once I exported it I tested it by clicking the resulting file but it doesn't open the application but rather it opens it in eclipse encoded. Please help I may just be an idiot.
you have to try to launch it with:
java -jar yourrunnable.jar
If you plan to run on windows and you want a .exe file, try to check this SO question: How can I convert my Java program to an .exe file?
or if you want to target a mac, you can have a check here:
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
Basically any platform you target you have some customization in order to achieve a seamless run. Anyway the most cross platform solution is the Java -jar way.
I had the same problem with .jar files not opening on a double click. It turned out that I had two versions of Java installed (Java 6 and 7). Uninstalling Java 6 from Control Panel-> Uninstall a Program was what finally allowed .jar files to open on a double click without using the command window.
What is listed in right-click-> Open With ? Is some other program listed as the default program ? Is a Java Runtime listed ? If a Java Runtime is listed, you can open with it, and make it the default program to run with.
Right Click -> Properties -> Change -> C:\Program Files\Java\jre7\bin\javaw.exe
For Java 8 use below
java.exe -jar myFile.jar
I am new to Java.
Basically, I developed a java projects which contains multiple Java packages inside Eclipse. The project runs OK on my desktop with a redhat Linux installed. However, I need to run it on a more powerful Linux server (redhat enterprise Linux) which does not have X11 installed. Therefore, it is impossible to run Eclipse on that server.
Is it possible to do that? If so, how can I move the entire project to that server including the input and output folders?
Thanks
In Eclipse use the "Export Runnable Jar" option. Highlight your project then click file->Export, choose Java, choose Runnable Jar file. Otherwise you can also use the javac compiler to compile your project and run it with the java command and your main class.
You will need to install the JRE on the machine you want to run it on. This can be done with the following command:
yum install java-1.6.0-openjdk*
Once you have java then it is simply a matter of executing your application. I would recommend using eclipse to compile your project to a jar and use the following command to execute it:
java -jar *JarFileName*.jar
Running Java is nothing to do with Eclipse . You can run your java program in linux machine by opening terminal .
Step1;- Set your JAVA_HOME in your bash profile .
Step2:- open terminal , go to the folder or package where your main program is present.
Step 3:- compile it using javac -cp lib.jar Filename.java
Step 4:- After compilation class file will be available , run it using java filename.java
Usually IDE like eclipse is for development not for running the application , but Linux version of eclipse is also available
http://eclipse.org/downloads/?osType=linux