blankabout
blankabout

Reputation: 2627

Eclipse - Publish & Run Simple Web Project

I must be missing something really obvious but I just cannot work out how to publish & run a simple JavaScript & HTML project to an Apache server on a local VM.

I have tried the locally installed Eclipse help but it always seems to come to an end without filling in the full details of what is required and there is no summary that gives a start to finish overview of what is needed to complete what should be a straightforward task.

My project is simple, it is comprised of links to a single JavaScript file and a directory of HTML files. I have created a server, giving the details of the Apache server on the VM, as far as I can tell I now need to link the project with the server but I can't work out how to do this task. If I right click on the project and go to Run As/Configurations the Create, manage and run configurations window allows me to create a new configuration but the server select box contains no servers.

I really have no idea whether that is what I need to be doing but I have tried so many options that I am now completely lost.

In the server window it says 'started, synchronised' by the server but it isn't even attempting to write files to the server directory (which is mounted on my file system).

I am using 'Eclipse IDE for JavaScript Developers' v1.4.1, 'Eclipse Platform' v3.7.1.

Could anyone point me in the right direction for publishing and running a simple JavaScript & HTML project on a local Virtual Machine?

Upvotes: 24

Views: 60413

Answers (3)

sethupathi.t
sethupathi.t

Reputation: 502

Before going to run your web project, you should have any of the servers like Apache Tomcat, JBoss, etc.

1.Right click on your project - Run As - Run on Server

enter image description here

2.Consider currently there is no server configured into Eclipse, so you have to select the sever (consider you have Apache Tomcat server) and configured into Eclipse and click finish. The server will be starts automatically and the project will be running in Eclipse internal browser.

enter image description here

enter image description here

3.If suppose server is not started - right click on the server - in the below server tab - select start option.

enter image description here

4.There is a chance to fail the server start - the configured port in the server may be used by other server, so you need to change the server port - right click the configured server and click open - change the HTTP port 8080 to some other port.

enter image description here

5.Start the server

6.There is an option to check whether your project is deployed successfully in the server or not. Right click configured server and click Add and Remove option - There will be showing available web project and deployed web project.

enter image description here

Upvotes: 10

Shaunak
Shaunak

Reputation: 18008

Publishing Static Content and JavaScript on Apache Server using Eclipse

Add Server

  1. Window -> Show View -> Servers
  2. Right click inside servers tab
  3. New - > Server -> HTTP Server -> Next
  4. add publishing dir: in my case (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs)
  5. Next -> add port (12345 in my case)

Create a web project

  1. Switch to Web View (Right hand top corner)
  2. Right click Project Explorer in left
  3. New -> Project -> Web -> Static Web Project
  4. Name the Project
  5. Select Runtime Target as HTTP Server
  6. Next -> Notice your default context root
  7. Finish

Copy your current js and html files in the 'WebContent' directory in Project Explorer.


In Servers Tab

  1. Right click HTTP Server
  2. Add - Remove -> Add your project -> Finish
  3. Right click Http Server -> Publish 4 done!

You should be able to see your stuff in publishing directory. you can access the page at

http://localhost:/context_root

cheers!

Upvotes: 20

Francis Upton IV
Francis Upton IV

Reputation: 19443

I tried this and was able to get it to work by doing this:

1) Delete the server you have in the Servers tab. Also go into the Preferences -> Servers -> Runtime Environment and make sure you have your server set up the way you want. If you are using a real web server for example, use an HTTP Server and specify the port, and the path of where to publish to (this is where it will write your stuff to).

2) Create a new server by right-clicking in the Servers tab. This will have you select the server you created (or used) in the Preferences (above) and then it will let you select the projects in your workspace to associated with the server.

3) Right click the server and select "publish", and you will see your artifacts in the directory that you selected for your server. You should now be able to access them with the server.

(It's not that easy to figure this out when you first get started, so I understand your frustration).

Upvotes: 1

Related Questions