Why i don't have .jar? - java

When download a file like "example.jar" the file isn't .jar is just a white file.
I tried finding an other .jar file from my java folder and Run As.. it but it just runned cmd for 1 second and then closed it.
Can anyone tell me what to do?

You have to run it via your cmd with command:
java -jar NameOfFile.jar
And you do not see the file extensions, because you most likely told windows in folder options to hide them.

Related

How can I make .jar files to run on my computer? [duplicate]

This question already has answers here:
'Java' is not recognized as an internal or external command
(19 answers)
How to run a JAR file
(12 answers)
Closed 1 year ago.
I've searched for a while for a fix, I think I've tried all of the common fixes, I even tried Jarfix. I have JRE installed, and I deleted and reinstalled it again just to make sure, I'm running Windows 10 64 bit. If I double click the .jar just nothing happens, and I've made sure that .jar is set to open with the right file. I don't know what to try so if you have any suggestions, I'll try them, because I'm completely lost.
Whenever I try to run any command starting with "java" is gives me this: 'java' is not recognized as an internal or external command, operable program or batch file.
First of all, Add your JRE to the PATH of Windows.
When you add it there, running java commands in the command line, will be recognized since JRE will also be indexed.
This is how you add it:
set PATH=%PATH%;C:\your\path\to\jre\bin\here
An example:
set PATH=%PATH%;C:\Program Files\Java\jre1.8.0_271\bin
Then go to the folder where your jar file is located. And open a command line there.
Or go there through the cd command (which means change directory to jump to exactly this directory). Example:
cd C:\Program Files\Java\jre1.8.0_271\bin
And then run your jar this way:
java -jar yourJarName.jar
.jar files have the java directory directly inside of them so you shouldn't have to reinstall JRE.
Maybe your .jar file you are trying to run isn't put together properly.
OR there is nothing to run on your file or there is an error in the code.
Those are all ways it could be broken.

Making a Java application for Mac users

I succesfully generated a dmg file thanks to this question. My issue now is that when I open the .app file, the program starts and immediately stops.
1) On Mac, how can I get the java error if any?
2) I think that the error occurs because the .app cannot access the files that are within the dmg. The same answer indicates that I could add my files to the .app file. I can do that, but then, how am I supposed to access these files from my application? What would be the path I should use?
3) For GNU/Linux and Windows users, I currently have a .jar file that updates my application by updating the myapp.jar file and some other files. If everything is packaged into the myapp.jar file, how am I supposed to do that?
Thanks for you help!
Have not tested the following but based on what’s described at Bundle Java program for Mac users with maven from GNU/Linux, the following are the steps I would try.
Open Terminal and cd to whatever directory .app is in.
Run find . -name java.
That will return something like foo/bar/jre1.8.0_112.jre/bin/java I guess.
Run find . -name myapp.jar where myapp.jar is the name of the jar you made.
That will return something like foo/bar/myapp.jar.
Run foo/bar/jre1.8.0_112.jre/bin/java foo/bar/myapp.jar.
If that runs, some error message will get emitted that should explain what else is not working.
Note that you can change files inside that .app directory; specifically, you can replace the jar file within the directory.

Java jar file not running

I have compiled my jar file using jar cmf manifest.mf SysInfo.jar *.class and got no errors, but when I try to execute the file by clicking on it nothing happens. I don't even get an error pop up. But when I run the jar using the console it will execute perfectly.
What can I do to make the file run by clicking it?
Try starting it via console using
java -jar yourFile.jar
Don't forget to cd in the directory your .jar file is located before you do this.
EDIT: Sorry, you already said it works like that. Try right click open with.. and then choose open with javaw.exe
If that also doens't work you need to provide more information.

Java cannot open executable jar file on Windows 10 (Open with...)

So...
When i want to open java executable file by double clicking it, system wants me to select program to open. Before It wasn't like this. it just opened...
when that window pops up, first thing is:
"C:\Program Files\Java\jre1.8.0_92/bin/javaw.exe" -jar "%1" %*
Selecting it nothing changes. I was trying to open it with .bat file and cmd, but it showed me error:
The System cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
i tried MANY different ways to do it, but nothing works :(
Also, I can write programs in Eclipse without any problems.
I am sure, that java files are "Executable jar files".

Compile and Run java program in linux with path to the .java file and path to external jars

Yesterday I solved a problem with an answer here on stackoverflow. But I ended up with another problem, I will try to be clear:
I have a project folder in the /home/demo/Desktop/xlsToCsv/ directory where inside of it is the java file "xlsToCsv.java" and another directory with the external jars that I need in /home/demo/Desktop/xlsToCsv/jars.
Now I need to compile and run my program. Yesterday I ran a command that assumed that I was already inside of /home/demo/Desktop/xlsToCsv/, and the commands were:
javac -cp ".:./jars/*" xlsToCsv.java
java -cp ".:./jars/*" xlsToCsv
The problem was solved and I was able to run my program without any problems. But, my program was supposed to run from the root directory, ie, the directory where it is when I open the linux terminal without the need to make a "cd" command.
So, when I open the terminal the path to the .java file is:
/home/demo/Desktop/xlsToCsv/
And the path to jars folder is:
/home/demo/Desktop/xlsToCsv/jars/*
Can someone explain to me what I have to do, and the reason so? Because more that run the program, I want to know the reasons and understand the classpath mechanism in java.
Avoid using relative classpath. and instread of "./jars/" use the absolute path "/home/demo/Desktop/xlsToCsv/jars/"
EDIT:
javac -cp "/home/demo/Desktop/xlsToCsv/jars/*" /home/demo/Desktop/xlsToCsv/xlsToCsv.java
java -cp "/home/demo/Desktop/xlsToCsv/:/home/demo/Desktop/xlsToCsv/jars/*" xlsToCsv

Categories