Hack Forums
[Java] [WTF] java independent programs coded in java[/WTF] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Java] [WTF] java independent programs coded in java[/WTF] (/showthread.php?tid=1656000)

Pages: Pages 1 2


[WTF] java independent programs coded in java[/WTF] - pikasas - Aug 26, 2011

Hey!

Could someone explain how some java programs are java independant? For example java crypters make exe files which can be run without java.

Moreover how can java produce exe file when its executable is a jar?

Thank you for your answers.


* - Will and Integrity - Aug 26, 2011

Is this possible? I've never heard of this before...


* - Beemo - Aug 27, 2011

http://www.excelsior-usa.com/articles/java-to-exe.html

Seriously the first link I found in a google search.


* - Eruditus - Aug 27, 2011

(Aug 27, 2011 12:00 AM)Herobrine Wrote:  http://www.excelsior-usa.com/articles/java-to-exe.html

Seriously the first link I found in a google search.

He means if he made a crypter in Java it would output an executable. Therefore giving it no Java dependency.


* - randomKID - Aug 27, 2011

For some reason, this thread confuses the hell out of me. Is the OP saying that the .exe contains some Java code and somehow, the Java code can be run without having the JRE? Or is he asking how is it possible that a Java application can output a .exe file?

Also, why wouldn't a Java application be able to output a binary file? The .exe will have different data than a .jar will but as long as you can output that data, you can create an .exe file.


* - Ben121 - Aug 27, 2011

If you have java byte code, you NEED the JRE to run it.

Sometimes people use native wrappers to wrap the byte code inside a native executable, but you still require the JRE.

In other cases, some people use compilers which convert byte code to native code, which doesn't require the use of the JRE.


* - Colby_ - Aug 27, 2011

tldr: Don't ever do this it's pointless.


* - soul_ninja - Aug 28, 2011

i think OP isnt talking about wrappers.
i think he means a Java application Producing an EXE.
which is still a dumb question.
i mean the java program can just write the exe file in byte code.

-
he says "For example java crypters make exe files which can be run without java"
so hes asking why when a java crypter ( a crypter coded in Java) can produce a crypted .exe file without any Java dependencies (eg. Java JRE)
Thats because the Java Program takes the original .exe (coded maybe in C++ or what have you) and only modifies that file to be undetected. The java program does not put any Java into the .exe file.




* - Virux - Aug 28, 2011

Right. If it's encrypting another executable, it's just reading the byte stream of that file, modifying it as it exports the crypted version.

A program coded in Java can be converted to an executable, many are. The JRE compiles the Java code to native, and runs it like an exe being 'javaw.exe'(I believe that's correct). So a Java-to-Exe converter would just capture that process.
However, if Java is converted to a native executable, it will lose its cross-platform ability. It will only work on the platform it was compiled for.



* - soul_ninja - Aug 28, 2011

(Aug 28, 2011 08:42 AM)Virux Wrote:  Right. If it's encrypting another executable, it's just reading the byte stream of that file, modifying it as it exports the crypted version.
This is correct
(Aug 28, 2011 08:42 AM)Virux Wrote:  A program coded in Java can be converted to an executable, many are. The JRE compiles the Java code to native, and runs it like an exe being 'javaw.exe'(I believe that's correct). So a Java-to-Exe converter would just capture that process.
However, if Java is converted to a native executable, it will lose its cross-platform ability. It will only work on the platform it was compiled for.
This is very incorrect

First of all the JRE does not compile the Java code to native code.
it Run the code inside a Virtual Machine (the JVM)

There is no such thing as a Java-to-Exe converter.
There are things called Wrappers as i referred to in my previous post.

But Wrappers only take the .jar file and "Wrap" it inside an .exe
The Java JRE dependencies are still there and its still a Java program.

The difference is the .exe can check if you have Java installed on the client PC, if not. Install it. then Execute the Java Executable, this among a few other things is what Wrappers are mainly used for.

But the fact remains you cannot convert a java program into .exe program magically and think it wont have any Java Dependencies.

BECAUSE

the JRE has all the libraries that the java program uses.
thats why it is always essential that the JRE is installed when running a Program coded in java.

/rant
:)



* - randomKID - Aug 28, 2011

@soul_ninja AOT compilers compile the Java byte-code into native-code so there are Java-to-Exe converters...

http://www.excelsior-usa.com/articles/java-to-exe.html

http://www.excelsior-usa.com/articles/java-to-exe.html#aot //Or click here if you only want to read the AOT stuff.


* - soul_ninja - Aug 29, 2011

(Aug 28, 2011 08:02 PM)randomKID Wrote:  @soul_ninja AOT compilers compile the Java byte-code into native-code so there are Java-to-Exe converters...

http://www.excelsior-usa.com/articles/java-to-exe.html

http://www.excelsior-usa.com/articles/java-to-exe.html#aot //Or click here if you only want to read the AOT stuff.

i seem to have been disproven :)
thanks for setting it straight.

so i guess my post was not necessarily needed.
Sorry Virux 😵


* - Virux - Aug 29, 2011

(Aug 29, 2011 01:33 AM)soul_ninja Wrote:  i seem to have been disproven :)
thanks for setting it straight.

so i guess my post was not necessarily needed.
Sorry Virux 😵

Haha, it's alright.
But yeah, in order for the program to run, something must be executing machine code(which would be the JRE). So it's taking the .jar and converting it(virtually) to machine code, to be executed. http://en.wikipedia.org/wiki/Just-in-time_compilation
That being said, an external program can snoop on this bytecode-to-machine conversion and use the converted bytecode for the exe.

I know this is the general idea, but I don't think the specifics are correct.


* - pikasas - Aug 29, 2011

Thank you for all your posts! Everything seems great. AOT's make java programs java independant (well let's say that after crypting they are still java programs).

Unfortunatelly, I don't understant one more thint. I'll use a java crypter for an example (again).

Let's say that we have got a java crypter and we are crypting an exe. Woohoo it produces our crypted file BUT its java dependant (?) because the stub is written in java too (offcourse you can use c++ stub but what is the point in making java crypter + c++ stub).

So as I understand to make our crypted file indepedent from java, we have to use AOT crypter with both the java crypter and the stub?

OFF TOPIC: does java have a self-compile function as .NET does (CodeDom)?


* - Ben121 - Aug 29, 2011

http://download.oracle.com/javase/7/docs/api/javax/tools/JavaCompiler.html