using eclipse to connect to remote machine[linux server] using ssh - java

I am searching out for solution to use any of the IDE's such as Netbeans/ eclipse to run .jsp and .java files from a remote machine using linux as the OS. The .java and .jsp files are on the server . So, an IDE which would let me access the server and let me update the files directly on the server would be great. I use SSH terminal to connect to the server to update and get files. Now, if there was an easier way to just have an access using IDE to the linux remote machine. that would be great. Please let me know regarding the same. Thank you very much for your time.
Regards.

Your best solutions would be either to NFSmount the directory on the remote machine to your local machine. Or install something like dropbox that will sync the machines.
Is your local machine windows or linux? If it's windows, you can use WinSCP to keep the remote directory in sync with the local one. It will auto scp files when they change to the remote server.
If it's linux, I wrote a command line python script that does the same
http://pypi.python.org/pypi/scpy/

I think what you want is the Eclipse Remote System Explorer. See Ikool's Blog for more details.

like falmarri said, it's best if u can sync your files on the remote machine to your local machine. you can sync them by either using his script, or manually scp'ing or ftp'ing your files.
but my personal preference is to use mercurial or svn or other repositories. in addition to being able to sync my files, i also have access to some amazing version control of my code.

Related

Install java on linux server programmatically

I am trying to set up the environment with Java, git, Jenkins and maven by mentioning the IP address of linux VM. I have written a code to connect to VM, create folders, and move files to folders.
Now I want to install all Java and others software programmatically. Ib tried to install Java using yum -y install java-1.7.0. There is no error but then Java is not installed.
Please suggest what needs to be done so that Java gets installed and java_home path is set programmatically.
Any help is appreciated.
We've been doing this at the office this week. It sounds like you want a solution which would include JscH because you've started down that path. What I have to offer you is a solution that uses Jenkins.
We set up a target machine (two actually) as Jenkins slaves. It's rather easy to do, but you do need to install a JVM. You might look at docker.
Once the Jenkins slave is connected to the jenkins master, we just instruct it to run scripts. Some commands require sudo and so we set that up so that it does not require a password to be entered. Alternatively, you could run the jenkins slave jar after already having sudo -- not recommended.
We made a pom.xml to fetch .jar files and tar.gz files out of maven and copy them into a specific location. Then we executed scripts that manipulated them. The scripts came out of version control via Jenkins, but other files we pulled out of version control using a script.
All in all, I have the following tips for you:
Debug a script by executing it without Jenkins, and then run it under Jenkins for some final debug.
Put plenty of echo statements into your scripts so that you can see what has gone wrong.
You're totally relying on the Jenkins log and print debugging. This is very time consuming. So you would do well to pay attention to point #1.
Good luck :-)

Making a java project, using MongoDB, run on remote server (ssh)

I'm trying to make a java project run on a remote server.
I've used Maven and the project uses a Mongo database. I've got access to a home directory on a remote web server. MongoDB, Tomcat and java are installed so the only thing I have to do is to transfer my Mongo Database and my project and making this all work and run.
However, I'm new to all this and I've got no clue in how to do this. I also can't find anything online on how to archieve this.
How would I go about doing this via SSH?
Additional info:
My project includes:
.js files
.java files
.html files
1 main java class which should run constantly
Actually if you are new for this kind of development, (actually it is more about deployment so popular tag DEVOPS anyway...) take it easy so use your application server and database in the same machine(which is not a suggested way for large systems).
Step 1 For ssh you need to create key read this document and create a key
Step 2 Make a ssh connection to your remote machine like
ssh username#yourIp
it will ask a password enter the password which is given by you when creating the SSH key.
Step 3 Install Mongo DB, Maven, Tomcat, Java to your remote machine.
Step 4 Copy your war to under remote machine webapps
Secure Copy war to remote machine
scp -vC ~/.m2/repository/com/foo/Example/foo.war username#yourIp:/home/Development/tomcat/webapps
echo "Copy to server"
Step 5 Run tomcat server Go to tomcat/bin directory run startup.sh
/tomcat/bin/startup.sh

Reload Classes via ssh on intellij-run jrebel tomcat server

I have a JRebel+Tomcat server run via IntelliJ on my Work (*NIX) machine, and occasionally I'd love to have JRebel update Classes/Resources when I'm at my home (*NIX) machine remotely connected via SSH.
e.g.
home $ ssh work
work $ cd workspace/foo/bar/baz
work $ hey-jrebel-go-update-classes
I handle this today by VNC'ing into my work machine, then in IntelliJ executing "Update Classes and Resources" on my running Tomcat instance, then log back out.
It's rather silly since I'm already SSH'd in. Is there a way to kick off this process via command-line?
JRebel features Remoting facility, which can be used to sync the changes via HTTP to the remote machine. For that, you should enable JRebel on remote Tomcat (via -javaagent:jrebel.jar) and enable JRebel remote plugin that create an HTTP endpoint for negotiating with the IDE plugin. -Drebel.remoting_plugin=true will do.
For more information you can check the tutorial for setting up Remoting with IntelliJ IDEA and Tomcat.
Otherwise, without remoting enabled, you can deploy the app with the rebel.xml config file which will point to the location where the exploded application is and JRebel will make Tomcat to load the resources from that specific location, so you could just synchronize from IntelliJ to that remote location via SSH. JRebel will then work as usual - monitoring the changes in the specified location and reloading the classes/resources as soon as they are being used in the application.
I'm not completely following what you are attempting to do. But if I follow, you basically want to issue a command to a remote server via SSH and, ideally, launch it from within IntelliJ IDEA. You could either:
Use the Terminal window (Tools > Open Terminal), start an ssh connection, and then issue the command manually.
Create an External Tool definition that uses plink (or an equivalent) to execute the ssh command to your remote server. You can create an External Tool Definition in Settings > [IDE Settings] > External Tools. See the screenshot below for an example. The definition (or its group if using groups to add structure to your definitions) will appear on the Tool menu. You can also map a shortcut to it via Settings > [IDE Settings] > Keymap > External Tools. For a multiple command sequence, you can either
write a local script that does it and use the External Tool definition to launch the script
write a remote script and use the plink in an External Tool Definition to run it
put the commands to run in a local file and use plink -m {file} to run them.

Eclipse Java Remote Project won't build and run

I have spent 6h+ and finally I've decided to seek the community's help.
I have a Java project on a remote SSH cluster and I have imported it into eclipse using RSE (Remote System Explorer). This project used to be a local project and has many libraries/dependencies. I have configured all of them and all of the paths are accessible on the remote cluster.
I want to run it on the remote cluster using SSH as well (via Eclipse External Tools). I have configured EVERYTHING and have even successfully ran another project. However, right now the problem is that Eclipse does not create even a SINGLE .class file on the remote server!!!
The project does not have any errors (if I just copy its bin folder from my computer to the remote cluster it works) but, since Eclipse does not produce a single .class file, there is nothing to run in its bin folder on the remote cluster.
It's also worth mentioning that for some reason that I don't understand, there is a red x on the projects name in Project Exlorer (indicating error) but there is no such thing on any of the source codes/packages in this project.
The "Build Automatically" option is active and cleaning and building it manually won't work either.
Any help is hugely appreciated as I am really desperate and need to get this thing working.
Thanks in advance.
I had a similar problem and this solution worked for me:
In my java context.xml file in the META-INF folder (local project context), I added path="/myProjectName" and it started building automatically.
<Context path="/jvals" antiJARLocking="true" antiResourceLocking="true">
<Resource name="jdbc/jvals"....
I was never able to solve this problem and the only thing I could think of was a bug within Eclipse. It seems that because of slow transfer rates to/from cluster, some of the files could not be built as they were partly fetched/stored. I ended up writing a shell script that would transfer the files to the remote cluster and compiled and ran it on there.
If anyone has a better suggestion, I will be very grateful.
I solve the problem in another way ;
go to the remote project in linux ;
cd youRemoteProject/build/classes
if your jars is in xxx\lib\a.jar, b.jar
java -cp ".;xxx\lib*" package.package.className
( you must using Java 6 or later, classpath wildcards are a part of the JVM )

Tomcat, Netbeans Mac OSX Lion

I've just bought an iMac and would like to start programming on it. But I can't configure Tomcat and Netbeans to work together. I installed Tomcat and it seems it is working. But when I try to build a web application, netbeans ask all the time my user name and password. I already configured the user.xml but it's not working.
Can anyone give a tip?
Cheers
I had the same issue and I followed #Raph's answer and it worked. After that, I had another issue, Netbeans returned this error message:
Deployment error: Starting of Tomcat failed, check whether the /Applications/Tomcat/bin/catalina.sh and related scripts are executable
To solve this, in terminal, I navigated to tomcat-folder/bin and executed:
chmod 755 *.sh
And it solved my issue, cause it made the scripts executable.
Add a new Tomcat server is quite easy on NB. No "install" as a traditional sense needed to do that:
Download any compressed (not installers) tomcat version from http://tomcat.apache.org
Just unzip (uncompress) in your preferred folder. You dont need do any thing else.
Go to Tools ---> Servers -----> Add server.
Select Apache Tomcat Server. Then on "server location" label, select the folder where you have uncompressed your Tomcat Server. You can define in this window your log and password. NB will automatically change your user.xml.
This is a good way to configure as many servers as you want, and easily configure its access and management data.
I hope it helps.

Categories