Get current state of Java interface from Jar file - java

This may be a weird request, but I'm going to ask it.
I have a open-source software, written in Java.I modified it for a project.
The software lets me place some elements on its interface and link the elements together.I modified the code to add some extra elements.
After compilation the software is generated in a executable .jar file.
The software only provides the option to sync with a certain server but I do not have access to that server.
Also,the software does not provide any save option to save the current state of the interface.
My question is : Is there a way to find and/or save the current state of the interface? Like an option to save current state in a temporary folder?
I tried to implement my own save option method but the software is huge, with many classes.all the classes are dedicated for the server sync.Hence, it is a difficult problem to solve.
Thank you!

Related

Proper default location for storing user generated data

I am designing a (farly big) application for a company. With this application the users can generate content in the form of XML documents, which they might want to share among each other.
It might seem like a trivial question at first, but I need a default location when the user clicks the Save As button. Unfortunately there are different operating systems and I haven't worked with all of them, so I don't know what is a common thing to do. The .jar could be executed from anywhere and the current execution directory doesn't seem like a professional solution. Neither does the desktop. Is there a way to get a proper system depended location I could use? On windows C:/Program Files/APPLICATION_NAME or C:/Users/USER/AppData/APPLICATION_NAME is often used. In my research I also stumbled upon C:/Documents And Settings/All Users/Application Data/

Publish updatable Java software through Wordpress

I have just written a Java program that I now need to publish. I want to make the software easily updatable, and I therefore need your advice. The program will be used by people with minimal technical knowledge, hence usability is absolute key. The program is not open source.
The situation is this:
First time users download a zip-file containing one .jar-file and two folders that should contain the program output files (.xml-files and .png-files). I want to make it as easy as possible for the user to update the .jar (replace it with another .jar, not necessarily at run time). To my help I have a simple web-based Wordpress site that the user will view as the source of the program.
I'll list the possible solutions I've come up with:
1 (fallback solution). The user have to manually go to the Wordpress site where I'll put a separate direct download link (from Google Drive) for the .jar-file. The user then has to manually replace the .jar in the existing folder with the new one.The drawback to this is that it requires too much work from the user, and they program probably won't get updated very often.
2. Alongside the Program.jar in the zip-file the first user downloads, I place another Program-Updater.jar. This new .jar's sole purpose is to, when the user opens it, download a new version of Program.jar from the web and replace the existing one.This is better than the previous option because it requires less work, even though it's not automatic. The drawback is that I need one more .jar which can confuse the user, and most importantly I have no way of updating the Program-Updater.jar.
3. Java Web Start.I've tried reading up on how this works, but I'm wondering if there is a way to get it to work. One possible problem is that I can't really access the host, and to be able to set up the .jnlp the correct way I think you need this. I'm also wondering how the program's file structure would be (is the .jar even placed on the user's computer?) and if this could confuse the user. Also how to make it always work offline.
4. Suggest your own solution!
Any input on this matter would be greatly appreciated, and I'll gladly give more info than I already have.
Cheers
Getdown was the way to go; it is extremely easy to use.
I'll put the .zip on Google Drive with a direct download link to it on my Wordpress site.
The files used by getdown are placed in and downloaded from my public git repo.

Open an unknown file that was saved in Java

I am doing data recovery for a company. They need one type of file specifically, created in a java software package from the government. Filenames are lost, but the files themselves contain the project name. You can only find these when you actually open them in that software though, the files themselves do not contain any plain text. There are many thousands of files, so we can't expect someone to manually open them and update the filenames.
An added difficulty is that there are several different formats of these files: the most recent version of the software can't just open files from the previous version, it needs to "convert" them. This gives me the impression that the files are simply Objects that have been saved, and with each software version they change their Class so much that old files can't be cast into their new Class anymore. Or something. It's been a while since I programmed in java. :)
In any case, I "simply" want to read a single property of that object. But I don't have its Class to parse it with (which can be one of many, depending on the software version the file was saved with). I have the jar files from that software, but am hoping I don't need to start analysing that whole software package to see what it does exactly.
So I finally get to my question: can I open such a file (assuming it's indeed a "saved Object"), and somehow parse its contents as plain text? I'm sure that once that is done, I can retrieve where the project name is saved - hopefully in the same place across software versions.
If they are serialized objects, the file will start with a magic value of 0xACED and then a protocol version number, currently 0x0005.
If so, you can't really parse it other than by deserializing it with Java code, with all the relevant classes available on the CLASSPATH in the relevant versions. The reason is that any serializable class can provide its own code to write to the stream, which therefore only that class will understand correctly.

How to load and save files in Android?

I need to load "configuration" type files for my program in Android, they are both .bin files containing dictionary data for the NLP library. I'm a bit new to Android still, and I'm having trouble finding a folder to place the files in so I can access them when the activity starts.
I also need to create/save/load a filetype specific to my program, and I don't know where to put it either. All I've been able to find on here is people using the getAssetManager() function to fetch input streams, but I explicitly need File objects for me to be able to load them into my pre-existing desktop software code I'd like to reuse (plus the libraries require them anyway)
I've also seen people using a "res/raw" folder, however the ADT did not generate this "raw" file when I made the project - so I'm not sure what to do there either.
Here is how I usually start the software in the desktop version, but I need to fetch these files in an Android environment:
brain.start(new File("memboric.core"), new File("en_pos_maxent.bin"), new File("en_sent.bin"));
core = brain.getInterpreter().getCore();
The memboric.core file can be generated, but I need to know WHERE and HOW to do so.
Thank you very much for your time, feel free to direct me to other resources if you feel this question is inadequate.
TLDR; how do I load "static" files for the software to function (needs to be included with software), and how to create/load/save "personal" files into an appropriate area of the device?
Use Context.getFilesDir(). Your application can read and write files in that folder and they'll automatically get deleted if your application gets uninstalled.
From that point forward, you can create, delete and read from files like any other Java application.
the "raw"-folder you can create it on your own. So check this out, which shows how to handle files in Android: http://developer.android.com/training/basics/data-storage/files.html

How to store high score inside a jar file

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.

Categories

Resources