I'm in internship, and my mission is to build a deployment program in Java. My approach was based on a "tasks to do for a deployment" model with dynamic instanciation (but this is not the point). Every task does something locally or on the remote server (sometimes both). For example, I have a Copy task which copies a local file to the remote server. Got some tasks like this for basic interactions (Move, Delete, ...).
The point is, each deployment module is a server which has different parameters (OS, connection params, ...) and basic programs. One of them is a Linux server, so I figured I could use SSH (with JSCh) to do the job. But the other is a Windows machine, with no SSH whatsoever. I searched everywhere for several days to find what could be used, with no results.
So here is my question:
what Java API should I use to get the job done?
Is it possible with Telnet or FTP?
Is it possible at all without ssh ?
Little detail: I don't have any control on remote servers, I can't install new protocols or programs, nor have a RMI server launched on them.
Thanks for your answers.
There are a few options to interact with a remote Windows server. If your local Java application is running on Windows (that is, both your source and target server are running Windows), you can spawn a new process and execute PowerShell commands - see this link for an example.
There are ways to copy and delete files on a remote server using PowerShell. Since you didn't fully specify your requirements, I don't know if that covers all your use cases or not.
If your application does not run on Windows, you'll have to resort to a pure Java solution like j-Interop to connect to the remote system using DCOM / WMI. See this page for a good introduction to WMI and j-Interop. Word of warning though - getting DCOM to work requires some configuration changes, specifically changing permissions on registry keys, on modern versions of Windows (Windows 7 and up).
Related
Are there any easy way to run a java code from the IDE (Intellij for example) on a remote machine (without jar)?
I am trying to execute the code that I am developing in a remote machine, without package and upload a JAR every time that i compiled the code. The idea would be to run the code on a remote machine in a simple way and see the result in the IDE.
Summary:
The main idera is execute the program as a normal script in another machine and be trasparent to developer. Execution looks normal but the code are being executed on another machine.
This is an exploratory question because im not find any similar solution.
Without having a better idea of the big picture, I'd say that this may not be something that IDEs are likely to make easy for you.
There are possibilities:
Most IDEs support plugins and custom tool integration. You could set up automation to transfer the files and invoke them remotely. You'd basically be doing all the work.
You could use something like a remote disk mount or an editor with remote file editing support to store the files on the remote server and then modify them locally and run them remotely using a remote shell.
You could use some sort of cloud IDE setup that would allow you to edit the files that are hosted on the remote server and invoke them. Tools like this exist, although you'd have to install things and it might be more work than the other options here.
If the remote server is a web application server (e.g. Tomcat), you could certainly have your IDE deploy a WAR to the remote server and then invoke it over HTTP.
I have developed an android application and i need to set a server for sending and receiving data from clients. The server must also be able to run python script for data mining.I want to code the server in java(for analysing the data obtained from mining and handling the client requests).
what will be the way to set the server for my purpose. I have read that servers can be set up in eclipse or installing apache in linux in a virtual machine. will anyone of them fit my need or is there any other better alternative.
Well, it depends on your needs. If you want to run Python scripts from Java, I don't really see why you would code your server-side logic in Java and then use Python data-mining scripts (you might have some problems with execution of Python scripts through Java and server setup). I know that Python is much better in data-mining, so stick with it. Consider Python for server-side logic. In case you want to run data-mining script manually that doesn't really mater, so you can separate the languages.
In case you want to separate it into two languages, then you must install an application server for Java. There are plenty of options for that, even open-sourced (Wildfly, Glassfish, ...):
https://blog.idrsolutions.com/2015/04/top-10-open-source-java-and-javaee-application-servers/
You can set most of them in Eclipse for development, for production releases they can be installed either on Unix or Windows. The Apache option you mentioned is probably Apache Tomcat application server. You can read more about Java application server set-up in Eclipse:
http://www.eclipse.org/webtools/community/education/web/t320/Configuring_an_Application_Server_in_Eclipse.pdf
Depending upon the requirement, you can setup the server in many ways in any operating system like linux (fedora, ubuntu), windows, mac osx etc. There are many java web frameworks to follow to make your own server and provide API for mobile.
These are some java web frameworks:
playframework
Spring MVC
Grails
You can setup above and other frameworks and can setup in any enviorment. For initial, you can setup in your local system, then later you can upload into your remote server.
For setup, please see the respective framework's documentation.
It would be wise to choose json for communication between mobile and server. You can consume the API in android using default HttpURLConnection or you can follow other opensource http connection library like retrofit, asynchttp etc.
I would like to know if the following is possible:
I have to create a Java application that runs .sh files from different servers, I have my class to execute shells, with Runtime and Process, it runs .sh files from my computer, the thing now is that I would like to know if instead of my location be
process = runtime.exec("/home/user/Documents/example.sh");
could be:
process = runtime.exec("180.150.2.***/server/user/Documents/serverExample.sh");
and the thing is, that to get the .sh files from server, I have to login, this application could be a desktop application or a web application, but has to be in Java, so, how could I do this?
I appreciate your help.
Chema.
Basically, I don't think you can do that, the way you are trying. The Runtime.exec(...) will delegate to the OS to perform the actual execution.
There are any number of ways to achieve what you want, either purely in Java or via additional utilities based on the OS.
You could SSH or telnet to the remote machine and execute the commands via those interfaces.
You could write a client server app, where the server would allow you to send commands to it to be executed on your behalf (but you must understand that this is a massive security risk).
Check out Jsch or Ganymed SSH. I have used the latter to perform ssh/scp tasks programmatically.
I asked this on superuser as well, but with no answers (even no views). If it's wrong to mention it here, please let me know or just move it. Thanks.
We are using a shared server (six people with root access for each user), which is reinstalled and -configured soon. I agreed to install GlassFish for everyone to use. However, I am developer and do only know basiscs of Unix/Linux.
Now my question is, what do I have to consider if I want to meet these requirements:
Automatic startup on reboot (did not happen often in the past)
Easy integration with Apache
Usage of existing MySQL/PostgresSQL instance
Patterns/Tools for easy (shared) usage (installation of Java EE apps, administration)
Patterns/Tools for easy (shared) monitoring (resources (mem, db), applications)
Tools for easing remote development (EJB/WAR deployment, JRebel?)
Of course, there might be other topics I forgot which should be addressed.
Automatic start up under FreeBSD can simply be implemented using a start-up script which should just do 'asadmin start-domain' to start glassfish and 'asadmin stop-domain'. I'm sure there's a number of articles on start-up script creation for your version of FreeBSD (I would check FreeBSD Handbook first).
As to remote deployments - you just need a local copy of glassfish and should use it's asadmin utility - it has command line arguments that allow doing any administrative tasks with remote glassfish installations as long as you have admin password on them.
If you have experience with Windows only then I would strongly consider using a Windows box for this. The Glassfish distribution has functionality to register a given domain as a service, and I would suggest that you just create a domain for each developer.
Is it possible to get the following information via Telnet?
Software version
config files
config register
information on traffic and errors
If you have sample code that you could share that would be really useful so that I can procceed further with your help .
I will be thankful for your valuable replies.
Telnet is nothing more than a communication protocol to generally a shell interface on another Unix machine. The remote telnet daemon will most likely invoke authentication and shell processes so everything that you are requesting is yes, possible though you will thus require authentication.
As you know telnet for shell is primarily used internally inside secured networks and rarely on the 'net any longer.
Telnet is wrong protocol to do this kind of stuff. It is an (out-dated) protocol for interactive terminal sessions. You should be looking at "ssh" to execute commands on the remote machines, and then figuring out which commands you need to execute to extract the information of interest to you.
Some of the information you are after may also (in theory) be available using SNMP, but things like configuration files and application versions won't. The "ssh" approach will allow you to harvest any information that is available via commands run from the command line.
Injecting Java into the mix is almost certainly a bad idea. Java is best at tasks that are platform independent, but what you are trying to do is inherently platform specific.