I am developing a standalone desktop application in SWT which makes use of several images.
These images are included in my application's directory structure. So, just to make a silly example, anyone could replace my logo with theirs, claim the application as their work and brag with friends.
What is the most efficient way to prevent people from modifying or stealing the images used in my application?
Technically, you can make it harder (add the logo to the jar, use encryption, sign jars etc.) but AFAIK you cannot prevent it.
Legally: make clear under what license you distribute your application and what your trademarks are.
You can embbed them in a JAR file but it is still possible to change them.
You can try to encode the file as Base64 and put the result in a String class member, and when you need it you decode the String (quick but very dirty). It is still possible to decompile the class and change the content but it is harder.
There is no magic solution, unfortunately.
Related
I am a beginner Java developer and I have created an application in Java (Netbeans).
I have used buttons icons, backgrouds for jframes etc. When I built the project, they can easily accessible using WinRAR. Anyone can extract my jar file and see all the images that I have used in my program. Even the images used in jpanel that is not accessible without password.
How can I hide or protect these images?
I have created a .exe file also using Launch4j but still facing same problem. When I right click on the .exe file, its easy to extract my whole program.
To be honest, if someone wants your picture, they are going to be able to get it. One can simply do a print screen. However you can still do somethings.
Remove the extensions for the picture files and give them crazy names - this will make it harder for people to find your pictures
Encript the files then have the application decript them when loading - I don't know how to do this but shouldn't be too hard to find, for instance you could save the pictures as a byte stream with some alterations then reload it.
Save the picture in some archive which only your application knows how to read.
But anyway even with all these things, I still know how one could get a handle to an open JFrame, look through the components, and then could get your picture. IMHO trying to prevent people for getting your pictures is not worth doing.
I want to make setup file for java swing application .
I am creating the setup by writing the script file and selecting the source file as jar and other necessary resources .
Now i want to make my jar disable to extraction .
Is there any way from which i make sure so that no can access the resources from my jar file either the class files or images etc.
thanks in advance
You can make it harder to get your resources, but you can't make it impossible. That's not a Java problem, by the way, but a general one of distributed software. In order to access your resources, your program (or in the case of Java the runtime environment) must be able to unpack them. Even when you encrypt them somehow, the program needs to include the decryption key and the decryption algorithms. A determined user can find these through reverse engineering, and use them to get your resources.
You could try obfuscating your codes.
This is the one I have used for obfuscate.
http://www.zelix.com/klassmaster/
You could find more tools for that.
You can use java webstart, your jars will be kept in cache so very its hard to access.
Java Web Start Guide
I am developing a small game in Java and I am shipping it as a single Jar file. I want to store the high scores/best times for that game somewhere. Instead of storing it in a separate file, I would like to store it in the application itself (inside the Jar) so that its not lost. Is this possible at all ? If so, how to do it programatically.
Java does not give you tools to modify the JARs which are currently run. If you really want to do it, you have to guess the location of the JAR by yourself (which might reside on a read-only filesystem) and modify it the same way you would modify any archive file.
Bottom line: it's a very bad idea, don't do it! See this question for a much more reasonable solution.
Nothing is impossible, but storing it in the jar file would make it very complicated. You might also end up with unwanted side effects like "Permission Denied" errors when the jar is owned by another user. Virus scanners might get nervous when they see jar files change without reason, etc....
I would look to the Preferences API for storing this kind of info.
I think it is a bad idea to try and store anything in the jar file. Another option is to have a web based service offered to the people playing with your game. The game could connect through a web service to your hosted server and then store everything centrally there. Not sure if it is exactly what you want but it's just an idea. It would also allow people to compete with each other.
Java JAR file is a ZIP-Archive, so you could possibly access it with standard ZIP-Tools and just extract one hisghscores.txt file, modify it and then pack it back again.
Hey i am hoping to write a program where the program automatically just copy pastes all my dad's documents from D:\office folder. So whenever I plug-in my pen-drive , the program silently copies all documents inside my pen-drive. Also all files should be pasted to a hidden folder in the pen-drive (so it remains private) . Synchronization capability also required ...So which language should be easy and where to get started ...any idea ??.
Seems to me that some spyin' is about to be goin' on here. :P
I'd recommend C++. Not extremely easy as .Net's tillyvally but fast, framework independent, convenient to manipulate Windows API. You wanna do advanced stealth app, you can't pick the easy way.
Why use the clipboard when you could just use shell commands???
Maybe write an autostart batch file on your pen drive that copies files to/from your flash drive as needed.
I infer you are on Windows. Window has a plethora of functions to manipulate files. A few functions are below.
CopyFile Copies an existing file to a new file.
FindFirstFile Searches a directory for a file or subdirectory name that matches a specified name.
FindFirstFileEx Searches a directory for a file or subdirectory name and attributes that match those that are specified.
FindNextFile Continues a file search.
MoveFile Moves an existing file or directory and its children.
On and on. These and many more functions are documented here.
File Management Functions
Copy or move the files to the pen drive.
HTH
I hate to be the person who suggests this (I don't like .NET that much):
Make a C# (or VB if you must) Console app, or Forms app (if you want to get fancy). The .NET framework will make this kind of program VERY easy and it might be fun. Unless you want to increase your proficiency in C/C++, i would suggest NOT doing it in those languages since there is a learning curve and it is a little complex to do some simple things.
"Just paste" or "synchronize"?
For synchronization, unison is a good bet, see http://en.wikipedia.org/wiki/Unison_(file_synchronizer). For "just paste", you could code a call to a batch calling XCOPY from with the Windows Autoplay mechanism.
Sounds like a secret covert operation you're talking about, though...
I think that you will need to do a lot of work to get a less than satisfactory result.
I would suggestion you instead have a look at DropBox, which is free up to 2Gb of storage which automatically synchronizes between all registered computers, plus has a special folder which allows for web access. Very nice.
I would suggest to use Camel framework of Java, there you can easily run service which will for example automatically copy data from your flash disk after plug in, to folder which you specify etc.
Good tutorial how to start is here:
https://www.youtube.com/watch?v=dmtXkA7FlwA
I'm just starting out on Android and Java programming, coming in from a C++ background. I was wondering - whats the best way to go about making a library/UI widget/component that I can license to third-party developers?
In C++ I'd ship the customers my headers and *.a files, but I don't know the equivalent in Java.
Are there any good resources or links about this, maybe even from general Java development standpoint.
you can define activities/services that are available for any other application running on android:
"A central feature of Android is that one application can make use of elements of other applications (provided those applications permit it). For example, if your application needs to display a scrolling list of images and another application has developed a suitable scroller and made it available to others, you can call upon that scroller to do the work, rather than develop your own. "
http://developer.android.com/guide/topics/fundamentals.html
Activities and services have some use but there is a whole class of functionality (fancy table viewer for sql) that isn't covered. You can do jars but I don't think you can have android resources in that file. The work around would be to have a Jar and require the user to copy and paste some text into the apps resource directory. You can look at the admob.com android SDK for an example of this.
Not sure about how Android handles this, but the typical distribution of Java code is a .jar file. A .jar is basically a zip file containing all of the compiled .class files in a Java project. There might also be resource/text/etc. files within the .jar. There is no concept of a header file in Java, so all you need are the .class files, and possibly a manifest file to provide some additional meta info about the .jar.
http://java.sun.com/docs/books/tutorial/deployment/jar/
(This is just a general Java answer, it may or may not apply to Android)