What the title says really. I've tried exporting it to a Runnable Jar File, checked the Manifest.MF, and tried running it with Java multiple times but with no luck. However, it does work when I navigate to the file using the command prompt and launch is using java -jar Name.jar. This shows it works but I just can't get it to launch by double clicking.
I guess you're trying to launch a commandline-app. This kind of application can be launched by double-clicking aswell. There's only one problem: Java doesn't create a commandline-window by default and instead uses the commandline of the parent-process of the JVM, which in case of double-clicking doesn't own a console-window. In other words: the output to the console gets lost somewhere in the depths of your OS and the JVM and the program hangs as soon as any input is expected.
(Assuming your on Windows OS), if you right-click on it, do you see the option 'Open with' and then 'Java (TM) Platform SE binary', or something like that? And if you opt to open with that, does it execute?
If so, then you've probably set .jar files to open with a different application by default. For example, I have my computer set up to open .jar files with jd gui as the default application.
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
so it was created from eclipse. Double click didn't work, a .bat file didn't work (it open cmd and close it immediately), i have updated java RE but nothing change. The only way to run it is to move it to C:\Users\user and open cmd and type java -jar xla.jar. I don't want to change any setting of the computer since i have to send it to my friend (this is a group project). Btw i'm on the new Fall Creator Window version.
try
java -cp xla.jar com.package.name.Classname
if you have main method on a specific class.. using a batch file and then run it .. if you cannot run it by double clicking just google and create a exe to run your batch file.
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
Why does command prompt open and close immediately when i open netbeans ide ?Although i do not want to use the command prompt, strangely it opens and closes by itself each time i open netbeans ide, and then opens the application itself and works just fine. I am curious to know why this happens. I've tried searching and asking some but could get an answer. Thanks in advance.
On which platform? It sounds like it's started via a shell script launcher (.sh / .cmd file), so the shell ("command prompt") is launched to run the launcher, and then the launcher script starts Netbeans...
Assuming you are using Windows:
NetBeans.exe is a 32bit application, but if you are using a 64bit JDK, the 32bit exe closes itself (because a 32bit executable cannot load a 64bit JVM) and then launches NetBeans64.exe - I think this closing and re-starting is the reason for the command line window to show up briefly.
If you start NetBeans64.exe directly, then this doesn't happen.
I had the same issue with Netbeans 8.0.2 on windows where commands were opening separate cmd windows.
Resolved this way:
Right-click on the shortcut for Netbeans or the exe (Launcher).
Click Run as administrator
It worked for me.
You can try to right click on the icon and go to its properties. Copy the value in the Target field. Paste it into a command prompt and run it manually. This time the command prompt should not close and you can see for yourself what the error is.
I have a Java application that runs great :) While uploading files, it uses the standard output to show progress : "System.out.println(...);".
When I run it in Eclipse, well it works perfectly, but when I run the JAR file, I don't see any console/terminal showing up and printing what I print through "System.out.println(...),".
How can I open a new terminal when my application is launched (it is a Swing application)?
Basically I want to be able to run the Swing application and show information on the side in a terminal / console. Why? Don't worry about why I want to do this ;)
Thanks a lot!
Regards.
Open terminal and run application as java -cp yourjar.jar YouMain or java -jar yourjar.jar if you jar is runnable.
I believe that you do not see output because you are running your application using javaw - the special windows-only variation of JVM that does not have STDOUT at all. If you want to click your application and see output map *.jar file to be opened using java instead of javaw. Alternatively write bat file that runs your application. In this case you will see console.
Use java instead of javaw to launch your application. Double-clicking on a jar executes it with javaw. Instead, open a command line window and type
java -jar thePathOfTheJarFile.jar
If you want to have something double-clickable, then write a shell script containing this command, and double-click the shell script instead of the jar.