I have created a java application in intellij ide. The application is working well. Now that my application is ready I want to transfer my java application from my machine to server and make it live. I have one server, domain and all the basic rights in the server. Can any one help me figuring out?
I am very new in this part. I dont know anything about hosting my own website and application.
The answer depends on what technology you use. If you use application that needs to be deploy into servlet container you can deploy it onto e.g. Tomcat.
Whatever technology you use you definiately should build your application - it also depends on what building system you use.
E.g.fFor gradle, you can use gradlew build.
For maven: mvn compile.
Tell us more details about technology you use to allow us to help you.
You have a java application (Dropwizard) and first need a server to run it on, which means that it must be a server with java installed or where you can install it yourself.
Then you need to transfer the application "fat" jar (typically you find this in the target directory, depending on how you built it) to this server and start it with java -jar my-application.jar.
Then you need to make sure that the port that the application runs on is available externally. This usually means that you need to have a web server installed (commonly nginx or httpd) which redirects from port 80 or 443 to the port of your application.
Only then is you app "live".
Related
I was able to create a JAVA Rest API Web Service using SpringBoot. How do I deploy it so not only my localhost can access it but other computers in the private LAN as well.
I dont want to officialy publish it outside. Is Glassfish the tool for this?
I want to have an endpoint like
https://privatewebservice.net/api/
in the private network that other people can use.
Thanks.
Deploy the rest on your tomcat server on port 80 and in other PCs in the private LANs update host file for privatewebservice.net to point to your PC's IP in the LAN
It needs to run an a servlet container(aka web server). There are many; Jetty, Tomcat, Glassfish etc. That servlet container will start and host your application and make it available via it's port(s).
You can run this process on any physical or virtual machine that is visible on your LAN. You could even use your own machine for this if it's visible to your LAN (barring firewall/network rules blocking the traffic).
To make it available to your LAN from your machine, find your machines internal LAN IP address (run ifconfig on Linux or ipconfig on Windows) and try accessing the app via that IP from your browser. If other machines on your LAN can see your machine, they should be able to access it too via that IP address (likely you will also have an internal DNS name for your machine which would be cleaner to use in case your IP address changes).
Obviously that's only good for development and testing. Generally for internal hosted applications for your company you would have a machine running somewhere that you could deploy the app to to make it accessible by others on your LAN.
It's worth noting that Spring Boot by default comes with an embedded server/servlet container. By default this is Tomcat, but can be changed to say Jetty, via configuration and changing default dependencies in your maven POM file or Gradle build file. The default will be fine unless you have some specific reason to change it.
To use this embedded server, use one of either Maven or Gradle Spring Boot plugins which will provide a set of tasks that can be used to build an executable Java jar file for the application that will run the application on the embedded server, and the application within it. This can then be run with something like java -jar myapp.jar
Technically speaking this would probably be the easiest way to deploy the application. With the only major requirement on the machine you are deploying to being a compatible version of Java. Although I'd recommend wrapping that app in a Docker image that already has Java on it and use Docker to run the docker image as a container. This means your applications' dependencies(including Java and it's specific version) are housed within the docker image/container and also means the machine that will run the app could host many different applications resource efficiently(RAM, CPU etc), with each managing their own dependencies. The machine hosting the app would then just need Docker installed on it, and doesn't get polluted with any other applications dependencies.
follow this step :
1- generate a war file of your Spring-boot project API - see here how to do
2- deploy it on tomcat server see here how to do
3- replace your localhost with your #adress ip (where the server is on and where the project is deployed)
I am trying to deploy a JSP/servlet onto a server. Not tomcat but on a real web domain. This is my first time doing so and so far I exported it into a war file and placed the file onto the server. Nothing happened which is why I am here. All the google searches seem to concentrate on Tomcat which I have already ran the project on. Advice?
Ok, let's get really basic. You want to see the compiled JSP in a browser, through some public URL, right?
First, find a place to host your application. You can try Digital Ocean (starts at $5/mo), EATJ (free version available), Amazon AWS (free trial available), OpenShift (free gears available), your own computer with dynamic DNS, or many other options available through Google.
Next, you packed your compiled code to a war file. That war file needs to be unpacked (deployed) using some software.
There are numerous ways to handle this (Tomcat, Jetty, Glassfish, etc.). They all have their pros and cons. Pick one and learn the very basics. Tomcat doesn't require a separate web server but you can set one up with it if you like. At this stage, I would keep it simple and not do that yet.
Lastly, set up GoDaddy (or whomever you used to get your URL) to point to the IP address of that server. If your server is running and enough time has passed for the changes to propagate, you should see your page.
There are plenty other J2EE server for example, JBoss and Glassfish. Each one has it's own way to deploy your war files. For example, Glassfish is throught a web administration console (https://docs.oracle.com/cd/E19798-01/821-1757/6nmni99aj/index.html) and in JBoss you need to deploy the war file in a specific directory (http://docs.jboss.org/jbossweb/3.0.x/deployer-howto.html).
It depends on which J2EE server you are using.
Now if you want to get your own server and configure it:
Get the server or VPS
Install JAVA
Install Apache
Install a J2EE server (I prefer glassfish)
Configure glassfish with apache (http://www.codefactorycr.com/glassfish-behind-apache.html) to use apache in front of glassfish
You may want to block the ports 4848 and 8080 used by glassfish
Deploy your webapp
Have fun!!!
PS: I'm assuming you have root access to the server
Easy Apache Tomcat 7 install after,
Run Code via SSH:
/usr/local/cpanel/scripts/addservlets2 --domain=domain.com
For Linux.
So I'm really new to the Java webstack world, and had a question on the most efficient solution to my problem. Some background information first; I'm running Tomcat on a Lubuntu 14.04 server listening on Port 80, developing on a separate Windows computer in Spring Tool Suite (developing Spring applications obviously). Currently, whenever I want to test something, I...
1) Export the project as a WAR file from Spring Tool Suite
2) Undeploy the old WAR file from the server from the Tomcat manager webapp
3) Deploy the new WAR file that I just got from Spring Tool Suite (which takes ~15 seconds)
Is there any faster way to do this? Normally, I wouldn't be opposed to just developing on localhost. However, I'm going to be doing a group project, so we would all need access to the same SQL server, which would be the one hosted on the Lubuntu 14.04 server.
How can I solve this issue?
Most IDEs have the ability to deploy to server for both development and production purposes.
Those that don't have this ability inbuilt, ususally have a add-on that enables this.
You can also use build tools such as maven or gradle to undertake these actions.
Since you raised a good point of working with others it is important that all are across the deployment process and that the process is standardised to ensure no weird issues/bugs pop up.
Silly question as I just started web dev. Consider that I've got the project build on Spring MVC Framework in the Netbeans (a web site). I would like to make it live.
What is the actual process of making it live considering the fact that I bought the domain and got the hosting? i.e. you upload project in the repository of hosting provider? (not sure if the question is correct, hence correct me if it's wrong)
Can I somehow connect the repository of hosting provider with my Netbeans to update my web site directly from it? (like it works f.e. with svn repository)
First of all, it's a java application that you want to host / publish, so you will need java hosting company.
You need domainname, you can buy one, or get free domainname (there's a few options, you can get free .tk domain, some hosts offer free domain with 1 year prepay as well).
Yes you can connect to your host's SVN with your Netbeans IDE. But deployment process depends on how you will set up your environment on host side. SVN is a place where you keep your source code, not a compiled java application. You can use your host's SVN server, but then still you need to compile java code and build war file which you can deploy under your java server. Some java hosting companies offer Apache Maven, which can helps in your case. Another solution is to build war locally, and upload ready app to your java host account (try to use SFTP or SCP, most of java hosting companies offer SSH access to your account, try to avoid FTP as it's pretty unsecure).
I am currently developing an application for some researchers in my university.It's a small java program that you can use by command line. The next step is to package that program and deploy it to an application server. Some clients program will submit requests to the server who will call the tool that I wrote. Lately, we will add more tools to the server and he has to dispatch the requests to the right tool.
Which application server fits my needs ? I have looked for Tomcat, Jetty and Glassfish but it seems that they are only used for web application.
Is it possible to use those servers in some context different from web context? Which package archive should i use (jar, war) ?
Any advice?
Some clients program will submit requests to the server who will call the tool that I wrote.
The big question is what server-side technology and what communication protocol can you use between the clients and the server. You basically have two major options: HTTP and web services (in that case, consider using either JAX-WS or JAX-RS) or RMI-IIOP and EJBs (in that case, you'll have to use a Java EE compliant server like GlassFish).
I have looked for Tomcat, Jetty and Glassfish but it seems that they are only used for web application.
Not really. As I said, they can also be used for web services oriented applications. And GlassFish can be used for EJBs applications.
Which package archive should i use (jar, war)
The packaging will depend on the type of application you'll write, it's not something that you choose upfront, it's just a consequence. EJBs are packaged in an EJB JAR and typically deployed inside an EAR; Servlet based web services are deployed inside a WAR.
You really need to think about what technology to use first (with the current level of detail, I can't provide more guidance).
Do you even need an application server? There's nothing stopping you from adding the necessary network bindings and deploying it on its own.
Of the servers you mention, you've got 2 different categories: servlet containers and full-stack Java EE servers
Tomcat and Jetty are servlet containers. That doesn't mean that you can only do web stuff with them and you could manually add the required libraries to get a full Java EE server.
Glassfish is a full-stack Java EE server and can be compared with JBoss (both are open source) or the commercial rivals Weblogic and Websphere.
Sometimes this question is simple as the environment you are working in mandates a particular flavour of app server. You should check this first.
If you're not forced to use an app server, I'd ask why you think you need to use an app server?
I don't see why you would want to use tomcat, glassfish or jetty for a command line program.
If it's command-line based, and you want it to run server-side, you could write a little program that allows users to, for instance, telnet to your server, which in turn starts the CLI-application in question, and relays input / output to the client.
You may also want to look into Java Webstart, which makes deployment of new versions a breeze.
Actually we can't answer with so few elements.
- What are you planning to do
- With what technologies
- Where are you planning to host your application (have you got budget?)
- In which language are written the clients (even the future ones)?
- Could clients be on mobile phones (add some technlogy constraints...)
....
It would also be great to know what kind of request the clients will do, and what kind of response the server will provide...
Actually with what you tell us, all those application servers can do what you want...
I have looked for Tomcat, Jetty and
Glassfish but it seems that they are
only used for web application
You could even make a webapplication (servlet) and on the clientside use a httpclient to call that servlet... there are so many options :)
vive Paris!