The scenario I am facing is that I am currently developing on a Windows version of Eclipse, which suits all my developing and debugging needs. However, my testing works only on a Linux machine, and I have a plain Linux server where I run my Java code.
So, what I end up having to do is constantly :
build in Eclipse -> export as a Jar -> SFTP to my Linux Server -> SSH to run/test the file
As you can imagine, this gets very repetitive. So I'm just wondering what the best approach to do this. It would be great if you guys help me, or point me in the right direction.
Is Eclipse truly all you're likely to need for the foreseeable future? If there's even a chance you might need a better build technology (e.g. Gradle or Maven both of which can be run from the command line, and so let you script all of the above), I'd bite the bullet and move to it now rather than putting time into figuring out how to cobble something together that works with Eclipse.
You should be able to automate the SFTP upload and the SSH command that perform testing in a batch script that you could run from the command line. (Exact syntax for those two commands will depend on what your SSH/SFTP client is, but if you're using something well-known like PuTTY then I'm sure there's plenty of documentation out there and you can post questions on SO if you get stuck on something.) So really the sticking point is the process of building your JAR, and that's very easy if you move to a better build technology than Eclipse.
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'm currently looking into what better ways there are for deploying/setting up webapps locally after code changes and database changes.
So far I've seen the following tools/ways come by, and attempted each of them:
ANT build target that compiles, makes a jar, a war file and deploys that to the tomcat folder
Gradle build in combination with the tomcat plugin, which already does a bit of a better job than option #1
Good ol' fashioned command line
Setup run configuration within Intellij to do the deployment for you
Write shell script and call this via command line (haven't tried this)
To be honest I'm not finding each of these the ideal solution. I find option #4 the easiest as it allows me to, via a short-cut, easily deploy my changes and continue. This has however not given me an option for database changes yet, probably just me that missed it.
My question is mainly what tools/ways are you guys using in order to achieve an easy and maintainable development environment? What considerations come with those?
Well, let me tell you what I do for local web app setup.
In your favorite IDE(eclipse in my case) i'll configure the application server plugin(tomcat or webpshere) from Eclipse marketplace.
This setup will help to auto publish code changes to the server whenever I make a change in the application. I use Maven build tool for the application packaging. However I'm not sure about the database side.
For the people that were wondering how I ended up doing and found the best to work for me.
I currently have configured my IntelliJ IDE in such a way that the tomcat instance is linked and can be properly controlled and deployed, including debug, from within IntelliJ itself. This allows me to, via an easy shortcut, instantly populate any resources changes (css, javascript, front end) or redeploy or even restart the server. Especially with a small application this works very well.
It is yet to be determined whether this would still work with a multi-module setup and a larger project size.
Should you want more information on how this configuration can be achieved, feel free to send me a direct message.
I have an eclipse (java) project that I would like to perform some testing on. It Looks like TestComplete may be able to do it, however it's unclear based on what I can find, how exactly to run this testing on an ECLIPSE project.
Do you just open the jar file using TestComplete and so thus using the Eclipse IDE is irrelevant?
Do you have to import the project into TestComplete somehow?
I found this: How Test eclipse product using TestComplete..?
Which I would have expected would answer that question, but really doesn't appear to answer the same question I read.
I'm trying assess if I can use this tool to test my software, but I'm a little unclear on how it works with eclipse in this case.
You need to run your application in a way whatever you want. After this, TestComplete will be able to work with the application: just record some actions and TestComplete will be able to play them back.
If you need to run the application from TestComplete, you can do this using the Tested Applications feature. It allows running a usual Java application using JAR file as well as running Eclipse as a common exe.
I would like to write a program that sends an automated email based on a timer that runs constantly. I would then like to somehow export this program from eclipse to a computer that does not run the ide, and run it constantly in the background. I have figured out the code to send emails through java, my question is more regarding how to export this project as an application (or something) that can be run on any computer without running it through the eclipse IDE.
Any help, or directions to a better a resource to learn from, would be greatly appreciated.
The simple (manual) approach to turning a Java program into something that runs outside Eclipse:
Create a runnable JAR following the instructions here: http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm.
If your application depends on library methods that are not part of the Java SE library, pay particular attention to the "select library handling strategy" step.
Run the application from the command line as follows:
$ java -jar yourapp.jar arguments ....
Obviously, you need at least a Java JRE installation on the execution platform to run java, and you should have configured your system (the $PATH or %PATH% environment variable) so that typing java runs the correct thing.
If you are using a build system like Maven, Ant, Gradle and so on, you can automate the step that generates the JAR. (In fact, you can automate the entire build ... and break your dependency on any IDE.)
I DO NOT recommend trying to create an "executable" for your Java application. For a start, executables cannot be run on any computer. They can only be run on computers running a specific operating system / OS family. A second problem is that you are effectively embedding a JRE in your application. That makes applying the latest Java security patches difficult.
As for the problems of keeping the application running "constantly" and sending emails at specific times, that is just Java programming.
Use Timer & TimerTask - e.g. http://www.mkyong.com/java/how-to-run-a-task-periodically-in-java/
Use a job scheduler. For instance Quartz has an easy to use API for running jobs on a fixed schedule: http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-06
You need to create a runnable executable. You can do this by following these steps: http://www.wikihow.com/Create-an-Executable-File-from-Eclipse
Regarding the timer/scheduler, you may consider using Windows Task Scheduler (on Windows platform) or cron (*nix platform).
You will probably need to provide more information about the requirements you have for the timer in order to get a more specific answer there.
Currentyl i am working on a Java Web Application something simple JSF + Spring + Hibernate textbook application architecture, but i find my self losting time on uploading my WAR into production every time i have to do it and also in updating MySQL scripts, so
is there any good practice to deployed Java Web Application quickly?
Edit
This is the current Process:
I work on localhost where i quickly
deploy with eclipse
If everything work fines i export a WAR with eclipse
Upload this WAR through FTP into (hosted) production server
Move this into tomcat webapps
Thanks.
Tip. I'm Using eclipse as my IDE and ain't using Maven nor Ant
There are a lot of tools you can use to automate the build and deployment process:
Compile application => deploy to local server => execute unit- and integration tests => upload WAR file to web server if all local tests pass -- this is exactly the kind of functionality that Maven and Ant were invented for!
If you want to get rid of the tedious manual work involved in these tasks, perhaps checking them out once more is not such a bad idea.
Also, there are more advanced Continuous Integration solutions, like Hudson, which help you to better integrate source code management and deployment processes.
But none of those will speed up data delivery.
It seems like your most pressing concern is to find a provider to make your internet connection faster: However you manage your build process, uploading the content to the server will quite probably be the most time-consuming part.
The single most important thing is being able to script the stuff, so you can let the computer automate it.
You may be able to get Netbeans to create build scripts for your eclipse projects so you can just run ant to create your war. If not, keep doing it manually.
Then you need to script the ftp-session. That is easy - many scriptable programs exist (or you can just use a modern Norton Commander clone supporting ftp), so script it.
Then you need to script the MySQL-script changes. This is not easy to suggest, as you did not mention what needs to be done, but you can probably get very far with a Perl script or perhaps a small stand-alone PHP snippet expanding a macro.
THen you need to collect all the steps in a single script you can then easily invoke...
(or you could just figure out how to talk to the Tomcat administrative console which allows you to update WAR files remotely - but that may not be feasible or I would have expected you to do so already)