• Post Reply Bookmark Topic Watch Topic
  • New Topic

Copying files (Windows + Unix/Linux/Mac OS) and executing them with CMD-line args?  RSS feed

 
Simon Cahill
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, dear Moose Saloon!

I'm new here and I'd like to introduce myself before asking any questions, if you don't mind
My name is Simon Cahill, also known as Beatsleigher, I am 16 years old and a die-hard when it comes to old computers.
My hobbies are programming (of course), mechanical stuff (e.g. works on my lawnmower), computers, gaming (Atri 500, once I've got it up and running again.., Sega Mega Drive II, Xbox 360, PSP) and Android devices.
At the moment I can code "speak" Visual Basic for Windows Desktop (.Net) but I'd like to leave that language behind me and move on to something a bit better.
So I decided to learn Java, as I can also code Android apps with it.

And now to my question:

I've been learning Java for a few days now, and yesterday I felt confident enough to use JFrame Forms and I created a program which compares to strings, and if the strings are equal, then a simplistic calculator shows up.
That's all good and fine, but I'd like to do some more complicated stuff, as that's the way I learn best.
But I haven't found any good tutorials online regarding NetBeans (Except the ones in the documentation section on netbeans.org).
So I decided to create a set of tools for Android devices.

But for this tool to work, I need a couple of files: On Windows I need two .exe files and two .dll files, and on Unix/Linux/Mac, I need four binary files. All of which I have loaded into my resources package in my project.
But how do I copy them to a directory, where my program can find/use them and how do I start these programs, once they've been copied to the file system?

Help is much appreciated.

Thanks in advance for your time and help
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Simon Cahill wrote:So I decided to learn Java, as I can also code Android apps with it.

Perhaps a word of warning: Android isn't exactly Java, as far as how things run, it just uses the Java syntax and parts of its library. If you are learning Java just to get at Android a couple of hints:
1) Do not use Java 7, only use Java 6, as Android does not have any of the new language features and syntax introduced in Java 7
2) Don't invest too much time in learning GUI code (Swing and the like). You can't use it on an Android application which has its own UI.

Simon Cahill wrote:But for this tool to work, I need a couple of files: On Windows I need two .exe files and two .dll files, and on Unix/Linux/Mac, I need four binary files. All of which I have loaded into my resources package in my project.
But how do I copy them to a directory, where my program can find/use them and how do I start these programs, once they've been copied to the file system?

When you are ready to deliver your application to others or run them on a different machine, you would use an installer which packages the Java application (usually a JAR) and all the resources, and installs them in a known location. The Java code could then find the required resources in that known location by calculating relative paths or looking at a configuration file (depending on your install tool). But since making an installer requires you to learn yet-another-tool, then for now I would suggest to go the easy route and build a ZIP archive with the files all together in a simple directory structure that you unzip on the target machine.

How do you run the applications? That I am not sure exactly what you mean. But if you mean how do you get the Java application to execute the external applications you provide as resources then you would probably use a ProcessBuilder (<- click that link for the API) to build the 'Command Line' used to execute the application.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!