Is it possible to convert an exe file to a jar file? - java

Is it possible to convert an exe file to a jar file?
Because I just made a game which is online and in .exe file format, and I have a server running linux. It may be possible to run the exe on the server, but one of the two ways would be very good for me!
So the ways are either:
Convert EXE to Java, or
Run EXE in Linux

is impossible. EXE (actually PE) is the binary format used by the Windows family of operating systems. It contains assembled machine code and import and export tables to interact with the operating system. JAR contains java bytecode. Sadly, they are not compatible (actually the JVM generates machine code from the Java byte code on the fly, but the other direction is not possible AND makes very little sense, too …).
Check out Wine. It emulates part of the Windows API so it can run a subset of all native Windows applications.

You can run EXE on Linux under Wine (unless you use DirectX or alike), but what's the use of it? Is your game a server side of some distributed game (i.e. game server with clients running on the client computers)?
Upd: One more option is to run a virtual machine with Windows inside on your linux server. This can be more viable.

Is it possible to convert an exe file
to a jar file.
Not unless the exe was made by Java source. and you have the source code. but then it isn't a conversion, its a recompilation.
Run EXE in Linux
Wine will run windows executables. But if you have the source why not just run it with java?

Related

Running Windows-Compatible .jar files on Linux?

Our CE project includes a .jar file which is written for Windows only for some reason. Unfortunately, I do all my coding related projects on Ubuntu and I'm really not willing to install VS on windows and start over on a new environment and lose a lot of efficiency.
The jar file requires some other files to work but the directory formats differ in Linux so I'm getting errors of it not finding the files when I try to open it from Linux.
I've already asked for the source code or a more compatible version but the TA's aren't really cooperative in my case.
Is there any way I could circumvent this problem and fix the incompatible directory formats issue(For example by running through wine)?
Edit: I tried decompiling the jar, but it wasn't fully successful and some of the files came out corrupted.
Because the original maintainers didn't think that this JAR would be run on other OSes, you're stuck placating their arbitrary requirement. You're going to want to use a VM (Wine isn't an emulator and you're going to run into significant pain using it and Java to run a JAR) to set this up and execute their JAR.
Once you get a hold of the source, you can build a new JAR which asks the OS which file separator to use instead of allowing the code to assume Windows. Or use NIO.

Run exe from java on Linux

I am not sure if this is possible, I wanted to run a Windows exe application from the command line from my java program - something like
Process process = Runtime.getRunTime().exec("myapp.exe --params");
The catch is that I would like to run the java application which calls the exe from within an OS X or Linux environment.
I was wondering if anyone has done this or has any suggestions on how it could be done? Thanks
Edit: thanks for responding. I did want to add that I would probably not want to use wine to run the exe and would probably want to create some type of wrapper around the exe file to call functions from the dll directly from java. I haven't done this before and was wondering if any pointers on this.
exe files are have a specific, Windows-only format called Portable Executable (PE). It's not compatible with the format Linux uses for executable files, not to mention differences in system calls between the two systems.
You can't just run an exe file on Linux, regardless of whether it's being run from Java.
If you really need it to work, you have two options:
Use a Windows compatability layer for Linux in the form of WINE (or similar tools)
Recompile your exe for Linux

How to make an exe file to run in all systems which don't having JVM?

I recently developed an desktop application using java....i made .exe file using launch4j...
It gets executed on machines that have only JVM...
Propose me a way to make it executable on machines that don't have JVM
You can use Excelsior JET to compile Java into a native executable file on Windows that doesn't depend on the JRE.
Another solution could be GCJ
I use WinRun4J
You just copy the entire JVM to your program's directory and create an .ini file with contents similar to these:
main.class=com.program.Main
working.directory=.
classpath.1=.\lib\*.jar
vm.location=.\jre7\bin\client\jvm.dll
where jre7 is the directory with copied JRE.
Be aware that you need to check if you abide by JRE's licence.

drag and drop files into a exe java

I want to build a java program that will take a python file and drop it into a .exe, thus starting that .exe and running the python file in it.
I have converted the whole python library into a .exe and I have build a boot system on it that just needs the python file to be dropped onto it. I have made this file so I can run python on PCs that don't have python installed. I would go with the .BAT method but so 32 bit systems have a hard time with batch drag and drop.
So I am asking for some code that would allow me to take a file and run it through another file. I hope this is the information you needed, if you need any more i will answer it!

Is it possible to convert a jar to exe using Ant build in Linux?

I have created an project and need to distribute it over Windows. I need to create an exe for it I already know that there is a lot of tools like:
JSmooth
Launch4J
Executor
Advanced Installer etc.
The installer windows are done in Java itself. Means like the selecting locations, licensing etc. the only thing I need is to create an exe that should open this jar. Is that possible in Linux?
For a Java app. with a GUI, Java Web Start is the best option. It is supplied and maintained by the maker of the JRE, and therefore works on Windows, *nix and Mac.
I do understand the need for an .exe on Windows and I've used JSmooth before.
I would just make a shell script which launches the program. I think a shell script is fine for Linux: icons aren't built into the executable and you can't discover the location of a usable JVM automatically.

Categories