I'm developing a java application from a ubuntu machine and I want to reach a remote file that resides on a ubuntu machine, I want a java code that makes me able to rename or delete this file. I have no idea about how to achieve this task.
Anyone can help me and thanks.
To go about this, first of you have to break the problem into two parts.
First part is connecting to the remote computer. So you will have to look for a better way to connect to a remote computer with java. For this there are several ways to go about it.
You can google it to get a head start. And then come back here when you get stuck
Also you can check out the responses in this link. They will help you out
how to connect remote windows machine by java?
The second phase is doing IO (input output) operations after a successful connection.
Here is a link for sample code with JsCh
http://www.jcraft.com/jsch/examples/Shell.java.html
Related
I am trying to write java code to execute remote commands on an SSH, similar to the one in this library: Chilkat Android SSH Execute Remote Commands.
However, I do not know where to begin. I do not need to implement the entire library, I only need to be able to send messages from my computer to a device through a SSH using Java code. Specifically I want to implement the Connect, AuthenticatePw and quickCommand methods in the library.
My question is what do I need to learn in order to be able to write a java file that does this? I would appreciate any links to relevant tutorials.
I am working on a project using a Raspberry Pi and a web cam to detect motion.
I have got it to a stage whereby it takes an image and saves it on my computer. What I am wondering is, is it possible to let FileZilla automatically upload the image to my webserver when a new image is taken? Or is there any other ways that I could achieve this?
Since the post is tagged java, I'm assuming that you're using a Java program already or have the basic knowledge to create a Java program.
On to the answer: yes, you basically have two options.
1. Upload from within the Java program. FTP is probably the easiest since most web servers will have an FTP server running. Here is a tutorial you can use: http://www.codejava.net/java-se/networking/ftp/java-ftp-file-upload-tutorial-and-example
2. Use another utility outside your Java program to upload the file to your webserver. rsync would be the tool of my choice (tutorial here). When on a Linux machine (for example, the Pi) or a Mac, you can run a script that syncs the content of a local folder to a remote folder every x seconds:
while true; do <rsync command hier> sleep 5s; done
Note that that sleep period shouldn't be too short or you'll end up running multiple instances of rsync.
When on a Windows machine, you need to find another way to run a periodic process to trigger the rsync.
Well what I am trying to do, in the long run, is to change some LAN properties when the an ethernet cable is connected to a computer.
I want to run my Java program each time a LAN network is detected. I found a couple questions as to how to do this in C++, but nothing related to Java, specifically. Would this just involve the way I distribute my final application? As in, I could use Jar2Exe Wizard to package my Java program as a Windows service and then just figure out how to run that at startup. But is there any way to do this within the Java program itself?
Don't know what your specific need is but you could try this. This shows how to run windows commands from inside java so you wont have to create an external batch file.
How to Execute Windows Commands Using Java - Change Network Settings
Also check out this answer which talks about retrieving network name in java. then you can combine both!
How to get the wifi network interface name in java
I created a small application that, when run, creates or updates some tables in a database by extracting data from some PDF files. Everything works fine in this desktop application, but the next step for me would be to make it possible for an administrator on a website to upload a PDF file and my Java program would then run and update the tables accordingly.
The problem is I have no idea where to start with this (the site isn't done yet, but I'm running some tests and it is going to be coded in PHP). I'd like to know what kind of technologies I need to let the server run the program and update everything as it would in the offline version. Sometimes it takes a while to update everything, so ideally, the user uploading the PDF could continue browsing other pages while the server does its job. (I'll probably implement something that when the server is done processing the file, it says if the program ended successfully or not in a log file)
Can someone tell me what terms to search for on Google or give me some pointers? I haven't chosen where my website is going to be hosted either, so if someone could tell me what to look for to know if they support running applications like this, I'd really appreciate it as well!
This could also apply to other programming languages as I know a bit of Python and C++ as well, so in the future I might have some applications in those languages I'll want to use on the web.
If I'm not approaching this the right way, I'm open to other suggestions, but the best solution would be to keep my Java program intact as I know it works exactly like I want it to and I'd rather not have to start it all over again.
If your host is *NIX based you can use crontab (Automatic Task Scheduler) to run your program at set intervals. Make it check if a "new" PDF exists, and run the program if there is. There may be a way to use Windows Task Scheduler type programs to do it on Windows. This is probably the easiest way.
Alternately you can use You can use shell_exec() in your php to execute a command on your *NIX system directly to run your java program.
I want to connect a remote machine(has a Linux operation system) from my Java Program and I want to run a script on it. I will process the result of that script(it writes something to console) too.
What do you suggest for me? If anything needed I can explain more.
There are SSH libraries in java. you can use them to execute scripts on a remote machine.