Sorry if this is the wrong kind of question but currently I have an Apache server which is configured for Pyjamas. All I used to have to do was: pyjsbuild example.py and the GUI would appear in my browser.
I decided to switch to Java, so I picked Vaadin as my framework. How do I do the equivalent for Vaadin? All I want to do is compile the java and have Apache recognise it.
I'm using linux and I'm very new to building web applications, previously I only ever built the GUI side of things, I never had to touch the server.
You need Apache Tomcat to serve java pages. Install it separatly or see http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html for information on how to hook them together.
Vaadin projects work just as any web project. You have to crate a WAR file.
For example, if you are using Eclipse, right-click on the project, choose "Export..." and under "Web" choose "WAR file".
If you are using Netbeans or something else, google "create war in netbeans/intellij/..." to find out how to do this step.
This will generate a file with the extension .war, which you will have to copy in the "webbaps" folder of your Tomcat installation. Restart Tomcat and the application will be automatically deployed.
If you do not have access to the webapps folder, go to Tocatmcat's "Manager App" in the browser and
under the section "Fichier WAR à déployer"(WAR file to depploy) choose the generated file and click Deploy.
To start with, make sure that go through Getting Started chapter in Book of Vaadin. In this chapter you will find overview of the required toolchain and step-by-step installation instructions. Your Linux distribution might have more documentation about installing JDK (For example, see Ubuntu wiki for Oracle JDK installation).
It will be convenient for you to connect Tomcat to Eclipse IDE. This makes starting Tomcat and updating your application easy. For example, see this [blog] for some videos about connecting Eclipse to Tomcat.
Please note that using Eclipse is just one approach and later you might want to see if IntelliJ IDEA or command line works better for you.
Related
I prefer to use Netbeans as my IDE rather than Eclipse. A few years ago when I looked into Google Web toolkit, there was no good Netbeans plugin for GWT and everyone suggested to use Eclipse. How is the situation now? Is there any better plugin on the market, or is Eclipse the best option?
I prefer Netbeans over Eclipse too. To develop for GWT, I used the following setup steps without installing gwt4nb plugin. Since I use an IDE for code analysis and editing help only, and feel quite comfortable manipulating files and directories in the source tree directly. Though this may not fit your case, I guess for many developers the steps should be good enough because you can treat gwt development just a normal java project.
Install JDK, NetBeans-SE. Extract gwt package. I have a note for gwt-1.7.1. If running on a windows 64bit version, install 64bit netbeans and jdk, and also a 32 bit JRE.
Copy the Hello sample from gwt directory to a directory out of gwt package directory. Create a project of existing java source code, and put the project under the same Hello directory. Then netbeans will create two files in the Hello directory: nbbuild.xml and manifest.mf, and create its own nbproject directory under Hello. I simply ignore these files.
In netbeans "Projects" window, right click on "Libraries" and choose "Add JAR" to add the jar files from the gwt directory.
In netbeans "Files" window (not the "Projects" window), you will see the original "build.xml" file that comes with the Hello sample. Edit this file so the "gwt.sdk" points to the location of gwt package directory. On windows 64bit, also add a "jvm" property under "java" task. It shall look like (only jvm=... is newly added):
<target name="hosted" depends="javac" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode"
jvm="C:\\Users\\youhere\\Programs\\jre6.32\\bin\\java">
<classpath>
Use "Files" window, click to expand "build.xml" file node. Then right click on "hosted" ant target under "build.xml" and choose "Run Target" in the context menu to build and run the hosted mode.
The ant targets from "build.xml" you usually use:
"build": Use this to build the javascript.
"hosted": Use this to build java and start hosted server and browser.
Once the hosted server is started, you can run "build" target to build the javascript and to have the result served by the running hosted server immediately without restarting the server. Use your normal browser to see the javascript version at "localhost:8888". You can set a different port by editing the "build.xml" file.
Usually I copy the Hello sample to a different directory, and use that as a start point of a new project. After that manually edit the files to match the project naming and directory structure.
I also copy the other samples from gwt package to a new directory, then build and run them to use that as a code reference. If you want to also develop the servlet, take a look at the servlet of DynaTable sample and create or copy the files into the same directory structure in your project.
A note about gwt4nb plugin: I installed it but figured out it is too heavy weight for me. With the above manual setup, I can do everything that I need to without any difficulty.
I would say Eclipse is the best free option. Intellij IDEA (paid edition) has also good GWT support but it is not as good as Eclipse.
I think the only official support goes for eclipse, see here : https://developers.google.com/web-toolkit/download
Based on my personal experience, if you want to have a good integration between GWT and your IDE, go for Eclipse. If you intend to use Maven, I also suggest M2E http://m2eclipse.codehaus.org/
EDIT
Forgot to say the most important thing. Netbeans by the way, seems to have a nice support of GWT but I never tested, see : http://netbeans.org/kb/docs/web/quickstart-webapps-gwt.html
I am sure this is not the correct and suitable answer. But if you like to trade off, this is just an idea.
sudo -i
cd ~/gwt
./projectCreator -ant build -out projects/myapplication
./applicationCreator -out projects/myapplication myapplication.client.MyApp
Then, you can import the project ...
In Netbeans create a new projects and choose 'Java Project With
Existing Ant Script',
Set Location to the myapplication folder created earlier
Set Build Script to the build.ant.xml file created by projectCreator
Set Project Name to something more appropriate
Open the project properties and under Java Sources click Add Folder.
Select the projects/myapplication/src folder and press OK
Please excuse, if you didn't like this approach.
Sounds similar with Battle for Eclipse and Netbean but you are talking about concern with GWT.
So , I think you can choice as you more prefer depends on your experiences. You can do GWT developing in various IDE because I assume GWT runs on it's SDK not on IDE . But there has some points of views. Example : easy to generate , test , develop ..etc on each IDE.
I also personally love NetBean due to beautiful GUI :) . But I am working with Eclipse IDE because our team has been developed and configured on it for a long time so we have hard to change IDE (sometimes very hard to change Eclipse version because we can't imagine new version will more reliable for our projects).But I don't mean Eclipse is the best option , as I described you may configure your GWT projects on any other IDE also as your experiences via GWT SDK.
"...and everyone suggested to use Eclipse." . Yes you will see most of sample projects for it were figured with Eclipse IDE. Only aspect for GWT , I think you have chance to choose NetBean IDE without any worries.
You can develop GWT project on NetBean IDE as follow...
1.) First off, download and install the gwt4nb plugin. ( you may have exp for install plugin on NetBean IDE )
2.) download GWT SDK and extract it to your specific location.
3.) create a new Java Web –> Web Application. Name your application and hit Next until you get to the Frameworks tab. If you have successfully installed the gwt4nb plugin you should see Google Web Toolkit listed. Select the Google Web Toolkit framework.
4.) Next, browse to the GWT SDK installation folder. Name your GWT module and hit Finish.
5.) Clean and Build your project.(don't be forgot to wait until successfully finished Build.)
6.) Run the project, your browser should launch and the button “Click me!” and the text “Hello, GWT!!!” should be visible.
Cheer ! now you can create GWT sample project on NetBean IDE.
You can also create GWT's
Test Case
Constants
Module
RPC Service
UiBinder
By right click on your_project > Other... > Google Web Toolkit.
Have some useful tips for you !
I don't know if some one asked this but I have a problem that I am working on this tutorial Hello World Example with annotation driven Spring 3 MVC in Eclipse .Now I am very embarrassed to say that how can I make war file to deploy on tomcat. Please guide me in this regard. Thank you
P.S: Just to inform you that I have Tomcat 6.0 and eclipse indigo 3.7
You have many options depending on the environment you're using; the more simple ways can be:
for testing purpose you can reference a Tomcat installation inside your Eclipse in the Severs tab of the J2EE perspective and add your Dynamic Web Project to it; then you can control (start/stop/debug) your server from Eclipse
to build a war to deploy, you can right click the Dynamic Web Project and choose Export War File
I would recommend using Apache Maven as it will help you much as you project will get bigger and your will have a lot of dependencies. You can try it as Eclipse plugin (m2eclipse) or use it from command line.
Ok recently installed a wamp xammp to be specific.. I have a requirment to use jsp for some server side communications instead of other stuff like php. My main issue is not knowing jsp enough or java for that matter to know whether or not what I'm trying to do is working or if its not and if its not is it cause of the code I'm tempting to try which is a copy and paste solution via Google for "jsp hello world". Xampp reports tomcat as active and running but I copy and paste the jsp code I find to see if it works and when I go to it in my browser I just see the source as if I were looking at it in notepad, so anyone got some advice? This is a stock install if the latest xammp.. the server runs fine other wise php and mysql included.
Make sure that the file has the .jsp extension and that it's been placed in a subfolder of /xampp/tomcat/webapps (and thus not there where you usually drop PHP files).
See also:
Youtube video tutorial - Integrating Tomcat with Apache using XAMPP
Install NetBeans IDE and follow this tutorial: http://netbeans.org/kb/docs/web/quickstart-webapps.html (before running application in this tutorial you must stop your XAMPP Tomcat).
Or if you want to use your XAMPP Tomcat, integrate it with NetBeans, create a web project using that tutorial, create a WAR file (by clicking on button Clean and Build) - this will create a WAR file in your project directory in directory "dist" and then copy this WAR file to your XAMPP Tomcat into directory webapps.
Start small, use NetBeans IDE, read some tutorials and experiment. Later you can switch to Eclipse IDE (IMHO buch better IDE, but requires much more customization than NetBeans).
Dont use Notepad.
Our company has developed a web application based on Struts2 + Spring + Hibernate.
My boss wants me to make a installation CD contains JRE, Tomcat, MySQL, and our product, so that the client can just click sth like installMe.exe and follow the wizard to complete the installation.
I used to deploy web application with war. Just put it under tomcat webapps folder, and start tomcat.
Which software should I choose to complete my boss's task?
Thanks, guys.
You need to create an installer script and tell the installer where to put the files. I have used two, advanced installer which creates an MSI or Nullsoft which is from the guys who created winamp. A lot of open source companies are using it. I'd recommend the fist one, and getting a license to do the more complicated stuff.
The installation of Java is handled automatically with advanced installer. There is even a cool java template you can start from.
I am relatively new Java developer that's been thrown in the deep end, my usual skillset lies in Microsoft products and C#.
However I have managed to write a nice web service using Restlet and incorporating Toplink and doing some database CRUD stuff, etc etc.
I developed this in Eclipse against Tomcat 5.5. I followed tutorials and examples and managed to throw something together that works.
I had all my jar files in WebContent/WEB-INF/lib directory of my project - I soon realised that when I export this as a WAR file and deploy in Tomcat, it takes these jar files with it and stores them local to the application.
Fine, but then when you try to undeploy the app, it only does it partially as Tomcat "holds on" to some of the jars it was using i.e. the Oracle JDBC, and Toplink ones. This makes sense as the web service was using these jars as there was a live Oracle connnection going on.
So then I thought I should have all these jars in a common place where all deployed apps can access them, that folder I believe is:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\lib
(in my case). This made total sense, it's logical as you don't want loads of apps on Tomcat all referencing the same jars. So I removed all the jars out of my projects lib folder and put them in the common\lib directory.
Now my app will not work properly - it can't find my source code in src, the custom bespoke code that I have programmed against these jars. It will only work if I jar up my source code and put in the directory stated above. Odd.
I am obviously very confused with class paths and build paths and all of that stuff, and must have got this sort of stuff all wrong as I am no Java expert, as I readily admit I have pretty much hacked this together - so can anyone explain to me in laymans terms how I should structure my project to get it working with jars held in a common folder in Tomcat. Or are there any good resoureces on the web to help explain to me what I should do.
Hope this all makes sense...
Here is a pic of my current project:
Sounds like you are not using WTP web project.
If you've installed 'Eclipse IDE for Java EE Developers' flavor of Eclipse, the WTP is already bundled in there. Otherwise here its update site -> http://download.eclipse.org/webtools/updates
Once you've installed WTP you should create 'Dynamic Web Project'.
In general I would recomment to put only your presentation layer here ( JSPs, CSS, HTML ) and put all pure java projects into standard 'Java' project that you later add as a dependency to 'Dynamic Web Project'.
WTP can run your web application under a number of containers, fortunately Tomcat is supported.
You will need to configure it through Window->Preferences->Server->Runtime Environments.
Once runtime envirnonment is configured, you can create your server runtime:
Right click in 'Servers' view.
Choose New->Server
Select server type: 'Tomcat v.5.5 Server'
(Optional) Change server name to whatever makes sense for you
Select server runtime environment: This is the Runtime Environemtn that you have configured previously
Hit 'Next' button
Add your 'Dynamic Web Project' project to 'Configured projects:' panel
Hit 'Finish' button
After the server is configured you can just run it, or you can put it in Debug mode. All source code referenced by dependent projects will be available for debugging.
NOTE:
From personal experience, I would not recommend using common/lib. Put all the jars that your web application relies upon into its WAR file. If you are worried about dependency tracking then start looking into Maven and m2eclipse.
Usually I put my jars in $CATALINA_BASE/shared/lib/
Please read this documentation for more clarification and specially Class Loader Definitions section.
Also restart the server after you copied the jars.
Go to Window > Show View > Other > Server > Servers, a servers tab will appear below with console tab. Click on your server and then F3, this will open server configuration.
Check Server Locations, and make sure you checked Use tomcat installation(takes control of tomcat installation) then click Modules tab below and it will show your installed modules, make sure the module is present or add it.