Automate Self-Extractor - java

I am a little new to programming so please bear with me. I create a lot of self-extractors that I upload to a ftp site which my clients then download (with the self-extractor putting the files I zipped up to the right spot). I am trying to automate this process on my end since it is rather repetitive.
I think I can figure out how to create the zip and how to upload the file once created but I cannot figure out how to create use winzip se to create a self-extractor from the created zip file. WinZip has a command line interface but WinZIp SE apparently does not.
Any help would be appreciated...I am planning on writing this code in java btw.
Thanks.

According to What are the differences between the full WinZip Self-Extractor and the Personal Edition version?
Self-extracting files can be created from the command line.
That being said, I'm not sure I would use Java to automate the tasks you are describing, it's not the best tool for that IMHO. I'd rather use shell scripting.
Update: (answering a comment from the OP) I'm really not a Windows specialist but I think that Windows PowerShell might be appropriate for the job (and it can be used to query a MS Access database).

If you need to compress and decompress zip archives, just use any other command line utility, which you will call from your Java app. For example zip, and unzip: http://www.info-zip.org/

7-zip is free and can do this on the command line, meaning you can make a batch script. 7za a -sfx MySelfExtractingzip.exe MyFolderContainingFiles/

Related

How do I compute the file path for a user-written settings file in Java (JavaFX) that is compatible with Linux, Mac and Windows?

My JavaFX program needs to compute a file name path for various user-written files such as the product-specific preferences. For example, "Do you want to open your previous file the next time the program starts" and so on. I have successfully experimented with https://github.com/dlemmermann/JPackageScriptFX and "jpackage" for Windows at least, so it looks like I will shortly need a way to code, in a cross-platform manner, the "correct" path in which to store such files.
Is there a standard API or coding technique that will give me a file path that the program can write using user permissions that is "correct" for these native platforms?
I am not aware of a single piece of software which would do that but I think my answer to this questions Java - Cross-platform filepath may be helpfull for you. It also mentions how the same can be achieved on Android for example.

Open a file with a java application

I made a text editor in java. It has a FileExplorer class which allows me to read and write to a file. Now I would like to know how I could open said file (text.txt) with my editor application from outside my application. Basically when I double-click on the file (text.txt) it should start my application and pass some variables(like name and path). The application is a .jar file.
I am not going to bother anyone to go through the 2k lines of code, so I won't post it in here. But it is just a JTextPane in a JFrame and a PrintWriter/BufferedReader reading and writing to the file.
PS: should preferably work cross-platform.
Thanks
This question is not about java. It is about mapping files to specific application using you OS tools.
If you are on Windows you have to map extension *.txt to your application. Take a look on this article for details.
Please note that your application must accept file path in command line.
To make association easier I'd recommend you to writer batch file that runs your application and also accepts file name in command line. Then you just have to associate your batch file with *.txt extension.
If you are on Linux association technique depends on your flavor, but you can google it. Obviously you will have to create shell script instead of batch file.
EDIT
Actually your question is mostly about installation process. There are a lot of installation tools that can do this work for you. Some of the tools are even cross platform (I can remember "install anywhere"). There are both commercial and free tools that do this.

Preprocess OpenDoPE Word file (Macro or docx4j)

I have recently discovered the OpenDoPE project. From what I understand from the walkthrough, .docx files must be preprocessed to replace repeatable contents for example.
If I understand well there are 2 ways to do it :
Using docx4j
Using a Macro
I am developing a rails web platform, and I'd prefer the preprocessing to be done client-side, so with the Macro. But then If I can only do it with java, I'll go with it
Problem : when I click the "inject macro" button in the OpenDop Add-in in Word2010, nothing happens :O
So two possible answers :
Explain how I can install this macro in the document
Explain how I can have docx4j to preprocess the document. ie : from a linux terminal, what command with what parameters should I type to preprocess some document.docx file containing repeatable-contents ?
I tried clicking the "inject macro" button in my Word 2010, and it worked, that is:
it prompted me to save a .docm file
when i opened the .docm file in Word, the macro ran
Trying to open the macro in Word's VBA editor though, I couldn't. Seems I obfuscated it :-(
I do have the source files floating around, which I'd be happy to put on GitHub.
Please note however, that it is 4yo unmaintained 'proof of concept' level code (whereas the docx4j code is actively maintained and used by a variety of companies).
For non-interactive processing using Java, see samples/ContentControlBindingExtensions.java
To invoke from a Linux command line, that would need modifying slightly; also you need of course to pass a suitable class path.
The other way you could do it is by installing this simple web app in say Tomcat.

Can Java access the search file system feature in the operating system?

In the recent versions of windows, you can hit the start menu and start typing to search for files across the filesystem. Is there a way to do that programmatically in Java?
My specific purpose is to allow the user to choose a file or directory. The user could start typing a file name directly inside the application and it could start showing suggestions. Much easier than navigating directories in a typical file chooser.
This post details a way to do this in Windows, by accessing the native functionality:
Query Windows Search from Java
And this one details how you can do something similar (using mdfind) under Mac OS:
http://lists.apple.com/archives/Java-dev/2006/Oct/msg00224.html
What you're asking for in the second part of your question could be done with a simple:
File dir = new File( "/path/to/dir" );
String[] contents = dir.listFiles();
The first part is a bit harder, but it could be accomplished inside Java using the same technique called recursively. (for(String fl: contents){ /* do the above */ })
You don't want to worry about supporting wrappers around command line calls here. That is anti-platform independent.
you could write JNI code to wrap+expose any windows native functionality.
If it's just for autocomplete style behavior in a file dialog, you don't need to wrap the native functionality, you can just use standard stuff in java.io.
Sounds unlikely ti be a part of Java, since Java is supposed to be platform-independent. Such searches should require some sort of index over all files, to be efficient, also.

How to read windows .exe file version?

I need to parse the file version and product version from windows exe and msi files.
Could you point me to the file specification or the library (preferably in Java) that does that?
UPDATE:
It turns out I cannot use winapi, as the code needs to run on linux as well...
You could use GetFileVersionInfoSize and GetFileVersionInfo functions to get file version and product version. I'm not guru in Java but as far as I know there is the possibility to use WinAPI functions.
I have a Delphi program which can analyze PE/NE headers in Windows EXE files - but not right here. I think it can be ported to Java easily as it does a binary analysis of the files.
Of course, using a JNA calls to Windows API could do the trick on Windows.
Edit: I found it, but there are some minor glitches:
The original aim of the program was to extract resources from EXE (PE/NE) files, as at the time the available resource editors only worked with the PE format (NE is used by Win3.1)
The UI does not display the version info, but the record structure is there for it
The UI is entirely in Hungarian, I can provide translation if needed
Some of the code comments are in Hungarian, except some record structure descriptions, which are in English
I don't know if it compiles or not by its own today.
The ZIP includes a compiled Win32 RESXPLOR.EXE
The code has some buffer overrun bugs here or there - should be easily to fix it in Java

Categories