Exporting WAR from Maven Source files - Eclipse - java

I am an absolute Java noob so please be kind. I moved to Java web development from PHP recently.
I have Java source code which contains looks like this:
src directory which has .java files
rsc directory which has hibernate xml files
log4jcnf configuration file for log4j
pom.xml file with libraries listed.
WebContent directory
build.xml & a javadoc.xml
Now I would like to export a war file and deploy it on a remote server.
How do I import the code into eclipse, and download the library files and eventually export a WAR file.
I understand these are very trivial questions, but all the resources online assume that the reader is a java developer.
What I have tried so far:
"Open projects from file system" - I locate the "Import Source" and Finish but nothing happens.
New "Dynamic Web project" - I uncheck "use default location" and select the location where my project files are and I get an error
"A project already exists on the file system at this location: /home/path/to/webservice. Either use "Import Existing Projects into Workspace" to create a project at this location or delete the contents of /home/path/to/webservice from the file system."

It might be good idea to read these short tutorials, in case you are new to Java Web Development as well as to Maven.
Maven for building Java applications - Tutorial
Using Maven within the Eclipse IDE - Tutorial
Introduction to Java Web development - Tutorial
Java web development with Eclipse WTP - Tutorial

Related

Eclipse Mars How to add plugin DERBY database

I know how to use DERBY using CMD, I followed the tutorials in Apache website. Now I will use DERBY in eclipse which requires the core and the ui zip files. I watched a tutorial on Youtube but when I open my eclipse directory there is no plugin folder but still I extracted the core and ui zip files and they created their own plugin folder but when I run the eclipse and create a new Java Project and hit right click there is no "Apache Derby" menu shown while in the youtube tutorial there is. Also I found another guide but I am confused at STEP 1. Here are the files I downloaded (already extracted in eclipse directory).

Configuring JD-Eclipse Java Decompiler plugin for Eclipse Java EE IDE

I installed JD-Eclipse to the exact specifications of the directions here. Now when I navigate to a .class file via File > Open, I receive this error:
The Class File Viewer cannot handle the given input ('org.eclipse.ui.ide.FileStoreEditorInput').
Do I have to configure the plugin, or do I need to add the .class file to a project repository or something like that?
FileStoreEditorInput is used when a file is not in the workspace. It looks like jd-eclipse can only open files which are in your Eclipse workspace.

importing an eclipse project from file system, then running on server

I am trying to do the spring security tutorial at this link.
In the section entitled "Running the Tutorial application without Spring Security", I took the following steps (adjusted for differences between the current version and the version that was in use when the tutorial was written):
1.) I downloaded the latest release of the Spring Security Distribution,
2.) found and unzipped a war file in the dist directory called spring-security-samples-tutorial-3.1.2.RELEASE.war
3.) Renamed the resulting folder spring-security-tutorial
4.) Created a general project in eclipse called spring-security-tutorial
5.) Imported all of the contents of the unzipped spring-security-samples-tutorial-3.1.2.RELEASE.war
6.) Right clicked on the project in eclipse and selected configure...convert to maven project
7.) Then right clicked on the project and clicked run as...
But there was no "run on server" option. (I had chosen a general project instead of a Dynamic Web Project in hopes of preserving the file structure of the application to be imported)
I then started to repeat the process, but creating a Dynamic Web Project instead of a general project, and eclipse wants me to select the "src folders on build path". The file structure of the web application has 8 .class files in subfolders of WEB-INF, and I am not able to locate any .java files.
What steps can I take in order to download this and run it in eclipse on the server? With the ability to edit the classes?
I have read that I can select a .class file in eclipse and it will open the bytecode in the editor, so I imagine I can convert the class files to java files easily enough. But doing that within a general project triggers the error message that the class is not part of the classpath, so we need to get it in a working web project that can be run on the tomcat server from within eclipse first, I think.
A war file is a Web application ARchive (basically a zip). It is meant to contain a web application's compiled class files and resources (properties files, jsps, css, html, js, etc.). It a package that can be used by an application server (or servlet container) like Tomcat. Except through a Decompiler, you will not have access to the source code from the compiled .class files.
I doubt you can run this on Eclipse's Tomcat instances. Instead go to your Tomcat installation. Mine is at C:\apache-tomcat-7.0.22. Rename the war to something simple like security.war and place it inside the webapps folder, ie. C:\apache-tomcat-7.0.22\webapps\security.war. Go to C:\apache-tomcat-7.0.22\bin and execute the startup.bat Windows batch file. This script sets up the classpath and launches a Java application containing all the applications in webapps. You can see the startup logs in C:\apache-tomcat-7.0.22\logs\catalina.out (as you would normally in Eclipse console).
You can then go to localhost:8080/security to hit the application. Replace 8080 with whatever port you're configured on. security is the same name as the war file. When Tomcat starts (based on a config parameter) it will extract the war into a package directory under webapps with the same name.
You can play around with configuration settings. Some of the important ones are here.
You can shutdown Tomcat by running the C:\apache-tomcat-7.0.22\bin\shutdown.bat Batch file script. You'll have to do this and restart if you change something in the application (ex. the web.xml or a properties file).
I think the tutorial you linked was meant more for trying security settings than actually changing the source code. I'm sure there are other samples online for Spring security, I just don't know them.

How to open existing tomcat web application project in eclipse

I want to open my web application which I made using Terminal/Text Editor on Linux into eclipse on windows.
I tried to open it by doing Import existing project but I don't see my servlet files i.e .java files in it and i also see error mark on my WEB.XML.
ty154 is my project name.
My Directory structure is
Tomcat -> Webapp->ty154
Ty154->Images & ->webinfo
Webinfo->classes
I have my JSP files in the ty154 folder and Images inside Image folder.
I have my .JAVA and .Class file inside Classes folder.
Please help me how to open and configure my project in eclipse.
Thanks in advance !!
Its not possible to import the project that you have created using terminal/text editor in to eclipse.You have to create a Dynamic Web Project under eclipse and copy paste the java files under source directory of the project. The jsp and other html files will go in to WebContents folder of the project. Once this is done the eclipse project can be copied and can be imported in to any other eclipse installations.The best read is:http://goo.gl/hPVapt
As you have written source code in terminal environment so you wouldn't be having an eclipse project file to be imported properly. First you need to create an eclipse project and then you can add source from your code directories. This link describes it pretty well:
http://thusithamabotuwana.wordpress.com/2011/06/15/importing-existing-source-code-into-eclipse/
If you have the war file, then you can import the war file directly in eclipse. Go to File>import then select war
For this you need to have Eclipse IDE for Java EE developers
The "Import Existing Project" entry only works for Eclipse projects.
In your situation with a simple project I would create a new Dynamic Web project and copy in the sources to the source folder - just Ctrl-c the files outside Eclipse, and Ctrl-v them inside Eclipse - and the static files to the publish location. You essentially need to know what has been done to ensure it has been done right.

How do I install org.apache.commons.code.binary.Base64?

I am taking a class on Android and I am a newbie with JDeveloper. I am working on a Web Services application. I downloaded some code that has a "Import org.apache.commons.binary.Base64". JDeveloper is barking "not found" for this import. I found on the apache website the org.apache.commons.binary.Base64 module and downloaded it. What do I do now? I am not sure how or where to place this code. The downloaded folder has several folders and and way down at the bottom of one of them is my Base64 module. Sorry for such a basic question. I am using JDeveloper 11g 11.1.1.0.2 running on Windows 7.
If you downloaded the source, which is just Base64.java, just add it to your project as
org/apache/commons/binary/Base64.java
If you downloaded a jar, add that to your project classpath. In JDeveloper this should be available from the project properties dialog and select "Libraries\Classpath".
Of course, if you distribute this project it will need to adhere to the Apache license.

Categories