confused with Java EE exe and jar - java

In the existing projects where I'm working I see that there are Java EE jars like j2ee-1.3.jar existing, but when I try to download from Oracle website (1.6 version) I only see .exe available. So how are they connected, is it like exe after installation will create jar in the installation folder?
I checked the contents of exe with WinRAR but could not find any jar.
Also I have the same question regarding exe of JRE and adding it as external jar to eclipse project.

I suppose you are talking about the JDK installation executable file... So yes you guessed part of the answer, the JDK installation file for windows systems is an executable file that will do nothing but downloading and unpacking the JDK/JRE which is a set of java libraries jars (which you use for your development) in some directories you specify in installation steps.
This is the mains ubject of you question, but note that you will not only find jars when browsing the JDK installation directory, but a lot od other bunch, mains to be cited:
The java process uses for runnig your application.
The javac binary file used for code compilation... and many other staff

.jar is a library /package of Java and when you are on oracle to download it's application of java i.e. jdk or jre.
So when we do programming jars are used to add functionality, we will have to import classes from it.
when we want to use external classes then we have to use it's jar file.
when we do any import like import org.springframework.beans.factory.annotation.Autowired; it came from jar or dependency.
You can make executable jar file of java program, you can find out tutorial for it online. so whenever you click on that executable jar file in any machine where jre is installed you can access it. This is called Executable Jar, and you are telling about Java EE exe is setup application for New Fresh Java Installation.

Related

How to build msi installer which creates .exe instead of .jar?

I have some gradle project on java. I know, how to build .exe artifact by Launch4j from .jar. Also I know how to create .msi installer by gradle plugin 'setup-builder' (uses wixtoolset), which installs project folder with java libs and main .jar file inside. Now I want to combine both points but I can't find information how to realise it. Is it possible? If yes - how to do it?
Or maybe is there other way without wix/launch4j?
You can use Inno Setup, which creates an .exe installer. It's very useful because you can include some other program within the installation (like MySQL installer or Java installer). http://www.jrsoftware.org/isinfo.php

Wrap a executabe jar into .exe for using without jre installed

I would like to wrap an executable jar into a .exe file in order to give it to associate. I used Launch4j and it works. However the others are not able to use it. Error occurs always with Java version.
I found this question:
Running a java program as an exe in Windows without JRE installed
Is there nothing else more easy to use?
EDIT :
I slected prefer JRE rather than preferJDK und JRE window, that was the problem there.
In Launch4j, under JRE > Bundled JRE path, type something like ./runtime. When you wrap your JAR file into an EXE, the EXE will look for a java runtime in the current directory under a subdirectory called "runtime". If you copy a Java runtime directory into the same directory as your wrapped EXE file, it will use it.
In Windows Explorer:
The "runtime" directory is the complete JRE directory, E.G. "jre1.8.0_201", but renamed. Inside there should be a bin folder and a lib folder and some other files.

How to refer remote hadoop jar file?

how to add hadoop jar file avail in another computer(Ubuntu) using teamviewer, to run java program in windows eclipse.
TeamViewer doesn't affect your Java classpath.
Download the hadoop jar file and add it as a library to Eclipse. Or, better, use Maven/Gradle rather than messing with JAR files yourself.
Ubuntu / Windows doesn't matter. Java is cross platform

How to use jar files built by netbeans 8.0 on other windows?

I built .jar files of my application. Now I want to share them with my friends.
Do I just copy that .jar file over to my friend's system? If not, what else has to be done?
yes your can share the .jar file by just copy to the new system
if he/she is installed the particular version or latest version of java he/she can run that application
you can also wrap the .jar files into .exe file using some third party applicaion
In your comments you stated that the .jar files are unzipping and not running on your friends' computers.
This is usually caused by Java not being installed on their computers. They should get the Java SE Runtime Environment from Oracle and install it. Afterwards, the jar files can be run with a double-click.
If your friends already have Java installed, they might have to fix their file associations (so .jar files no longer open with their ZIP tool).
Yes if you created an executable jar it is possible to execute it if the operating system of your friends supports java.
If they need only to use your jar as a library they can import it in their project.
Yes just copy it to your friends machine. That is what jar files are made for.
The reason behind , your jar file is being opened as a zip file , may be your friend have set some unzip tool as a default application to open jar files. Try to open it with JAVA .

Cross-platform Executable Questions (avoiding duplicate)

I know that windows users prefer .exe (Windows EXEcutables) and mac users prefer .app (AppleScript application) and Java uses .jar (Java ARchive). But is there any reasonable cross-platform executable because to execute JAR you need the CMD or Terminal (at least in the case of a Mac) to run the file by using:
java -jar %FILEPATH%
But is there any other executable I can use?
Should I just have a Mac and a Windows downloads?
Can I make a jar that can be double clicked?
I have searched as far as I can in stock overflow but no simple reasonable answer.
Hope this can help more people than me :)
To be able to start a jar file via double-click, the .jar extension needs to be associated with the Java Runtime executable, javaw.exe under Windows. That is the same mechanism used to open for example .docx files with Microsoft Word.
As far as I know, the JRE installation adds such an association automatically.
In order to tell Java which class to start from the Jar after it was double-clicked, you need a META-INF/MANIFEST.MF in the Jar, like #Elliott Frisch described.
By the way: Mac apps are in fact folders, which Mac OS X shows as one piece (right-click on a Mac app and click Show Package Contents to enter that folder). So the idea is very similar to Jars, although Jars are real files and not folder -- and of course their format is totally different.
So a Jar is the format "executable" on all platforms (having a JRE installed).
An executable JAR file is the most portable cross-platform executable. Macintosh app files are Mach-O format, and not compatible with Windows Portable Executable. The Windows executable format is not compatible with Mac or Linux (ELF). Basically, the only format that will reliably run on Windows, Mac and Linux is a Jar File.
From Setting an Application's Entry Point the Java Tutorials,
If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application's entry point. You provide this information with the Main-Class header in the manifest, which has the general form:
Main-Class: classname

Categories