How to convert .apk files to java in android.
The extension Google uses for Android Applications (APK) may seem a bit complicated at first, but it really isn’t. In fact, an .apk is nothing else than a .zip file disguised as an .apk. That’s dumbing it down, but you get it. Essentially, if one wanted to see what’s inside an app, they would just change the extension of application-name.apk to application-name.zip, unzip it. And there you have it: The contents of the .apk! We aren’t done yet, read more after the break.
Here is where it gets tricky. Inside the folder where you unzipped the contents of the application, you’ll find a file named classes.dex. That’s the most important file of the whole application, containing all the java files, but it’s encrypted! No worries, that can easily be solved. You’ll need two things:
Dex2Jar from http://code.google.com/p/dex2jar/
A regular Java decompiler, such as JD from http://java.decompiler.free.fr
Copy classes.dex to the folder where you unzipped Dex2Jar, and run from the command line: “dex2jar.bat classes.dex”
This will produce a file, strangely named something like: “classes.dex.dex2jar.jar” If you have WinRAR installed, you can just unpack the files. If you don’t, install it.
Now go ahead and adjust it to your liking!
its easy just follow the below 4 steps :
1) Unzip your .apk to the folder and get the classes.dex file.
2)Place this classes.dex file inside dex2jar(you should download this) and execute ./dex2jar.sh classes.dex in the terminal.
3)It will create classes.dex.dex2jar.jar,place it inside jd-gui(you should download this).
4)Execute ./jd-gui classes.dex.dex2jar.jar---will generate the .java files.
You can't just convert a jar to an apk. It has to be compiled for android. Android's java library doesn't have all the swing stuff that's in normal java, so the app most likely would have to be re-written to work on android
Pretty sure MIDlets (MIDP jars) don't use Swing or awt. They have a separate user interface api under javax.microedition.lcdui (http://java.sun.com/javame/reference/apis/jsr037/javax/microedition/lcdui/package-summary.html)
As for converting MIDP programs to runnable APKs, there is certainly a way. Technically it isn't a conversion but the use of a wrapper around the unconverted MIDlet. This is the approach that Opera Mini for Android uses. More info:
http://edugoing.com/qna/index.php?qa=unanswered&start=40
Related
I've been trying to make a program that, evidently, opens a .zip file and extracts its contents into a .jar file(minecraft.jar, for modding Minecraft), but couldn't find any way to open a .jar file within Java to do so. Is opening a .jar file(not running it) and adding/deleting files within the .jar file possible?
First, #McDowell comment is the root of your solution: the java.util.jar package is where you'll find the tools you need.
Second, modifying the content of a JAR file on the fly is possible, but complicated and rather a lot of work. Would it not be sufficient for your purposes to open both files (the ZIP and JAR ones, if I understand correctly), extract them in a temporary directory, then re-compress the whole lot?
It seems to me the result would be exactly what you're looking for. It might take a bit of a while to run, but since it's a one-off, I don't feel it's a major issue.
Our organization invested in a java web application that we want to be able to develop upon. Unfortunately last developer left with only the .war file. How can we recover some of the class files, change them then redeploy as war again. We tried to do that in Eclipse but after importing as war, we could not configure build path. (which in my understanding, the war was imported as static project). I could not find "Convert to dynamic project" as said in eclipse help document.
A .jar/.war file is compressed using the ZIP format. You can decompress it using any zip utility like WinZIP/WinRAR/etc. and then use your favorite decompiler on the .class files.
Java Decompiler is the best I've ever come across. You could open your entire war with this.
There is another option for special cases: Have a look at aspectj, so you can
weave in additional code around method calls to fix bugs etc.
add fields or methods etc.
It works on the byte code level (it works with .class files).
As for the long run, grab what you recover using a decompiler, and start to replace class files step by step.
I have started getting into game programming.
My question is, that when I am working with files, either parsing data, writing to files, etc. Should I be using relative path names, or absolute pathnames, or something else which is better. I've heard about using jar files, but I am not sure
1. how that works
2. if it is a good way to do it.
So when developing a game that will be cross platform, what is the best method for managing files that the program will need to read from and write to.
there are several ways in which you can ship your code as a product. the most common are
packaging everything in one executable jar file.
having a set of folders where you place all necessary resources.
minecraft, for example, is written in java and distributed as a single executable jar file that contains all necessary class files and resources. to run the game (assuming you have java installed) all you need to do is double-click the jar file.
read this short tutorial about how to add a main class to a jar file.
either way, always treat classes and resources in your code as if they're in your classpath. for example, if you have a my.properties file on the root of the source tree then load it by using 'my.properties'. if you put it under a 'conf' folder then use 'conf/my.properties'.
i think it is the safest way not to get lost.
are you using maven?
The jar file is a zip of all your compiled *.class files and your resources. You can safely load your resources and even default data FROM a jar if you package your program, but you can NOT safely write data back to the jar. This detail is answered in depth already at
How can an app use files inside the JAR for read and write?
For information on how to package a jar see
http://docs.oracle.com/javase/tutorial/deployment/jar/
I'm working on a java android project. this project requires to use specific commands.
these commands are all developed in c++/c but I've been given two files (.jar and .so) that are supposed to "turn them into" java, so I can use them in my java android project.
The thing is, what am I supposed to do with these 2 files?? I've read a lot of stuff (mostly about creating the .jar and .so, but I don't care about this step, for I already have the 2 files)
I tried to import the .jar (import external lib), I tried to add the .so via the static loading :
//static {
// System.loadLibrary("MySoFile");
// }
All I get is a stack overflow error or a problem with the DEX file...
Has anybody ever tried to do this??
I don't seem to get the point here...all I want to do is being able to use the commands in the .jar file.... ://
thanks in advance!!
Take a look at this answer about adding jar files. '.so' files can usually just be drag and dropped to the project.
All you need to do is make sure the jar is in your classpath and you can then access the classes within this jar. A jar is just an archive of classes, you don't need to load the library into memory or something similar.
You may want to read the answer to the question here How to use classes from .jar files?
I want to evaluate a software solution where multiple people have submitted JAR files to perform a task on Windows.
Is it possible to check whether the JAR file performs any additional unwanted behaviors besides those it claims to perform on your machine?
First, you can use a JVM set with SecurityManager to do run your application in a way that it can have limited access to sensitive functions.
You can also set up a "sandbox" so the jar cannot have permissions outside of the sandbox... you could use chroot or a similar tool in a linux/unix environment.
1. You could use software from Sysinternals:
http://technet.microsoft.com/en-us/sysinternals/bb842062
You can see is program's writing or deleting something from hard drive with HardMon, or monitor any changes with RegMon... Check out their website, they have much programs and you can monitor practically everything!
2. Or you could install Sandboxie:
http://www.sandboxie.com/
and then run you program within sandbox ("virtual filesystem"). When you run a program inside of sandbox, you can see what files did the program make, and the best thing is that any changes that the program did will be undone when it exists, so it can't harm your system. :)
3. Also, you could try to decompile JAR file:
http://www.google.hr/search?sourceid=chrome&ie=UTF-8&q=java+decompiler
Yes and No. By default java programs can do the same things any native program on your system can do. This includes deleting and replacing any file it can access, depending on your operating system and your user privileges this may affect system critical files.
It is possible to restrict what java applications can do, applets and webstart programs usually are secured this way. Alternatively you can run any program as a different/restricted user or in a sandbox to limit the damage it can do.
If you do not trust the library/program always run it in one of the restricted environments mentioned above. It may crash if it does something it should not do, but it will be unable to do any damage.
I tried the solution from jensign.com and it looks like it restricts almost everything. The .jar application that I used to test wasn't even able to download a website. However I'm not an expert at this stuff so I can't tell if it is a 100% safe solution.
The JAR'd application can be launched under fully restrictive sandbox conditions (very similar to Java applet default security sandboxing):
java -jar -Djava.security.manager PropsFrame.jar
cite from jensign.com
Try a decompiler, like Java Decompiler:
http://jd.benow.ca/
It decompiles the .jar file, and shows you the source, though keep in mind it might be copyrighted:
By the way, why don't you ask for them to submit the source code as well, instead of just the .jar files?
Basically, .jar files are like souped-up zip files, and I believe even WinRAR can open .jar files. A quote from their site:
Java Archive File (a compressed file
for applets and related files) (.JAR)
Short for Java Archive, a file format
used to bundle all components required
by a Java applet. JAR files simplify
the downloading of applets since all
the components (.class files, images,
sounds, etc.) can be packaged into a
single file. Additionally, JAR
supports data compression, which
further decreases download times.
JAR file support is the same as ZIP
file support. JAR = ZIP + manifest.
The Microsoft VM supports uncompressed
and compressed JAR levels 0 and 1, but
not signed JAR.
WinRAR provides basic operations for
JAR files created by other tools: view
contents, extract files, show comments
and archive information.
You can use the convert function to
convert .jar files into .rar format.
You do not need to have any external
programs to handle these formats.
After extracting with WinRAR, you can view the source by following this link as an alternate method to JD.