Related
When I looked into Java EE6 doc and some other articles, Java EE6 is a platform.
To me, platform is just Java with bunch of API/framework available like JSF, JPA, Web services like REST. (more like bunch of jars maybe?)
So anyway I got Netbean6.9/Java EE6/GlassFish v3 bundle but figured I don't need JSF at all.
Is there a way to remove JSF from Java EE6 so that I can save some disc space on my server?
Sorry if my statement doesn't make sense because I'm not fully understand what exactly Java EE6 by reading documentation.. (or this JSF is bundled with Netbean6.9...)
Update:
I'm building REST web app so far using JAX-RS and JPA (toplink essential) and for UI side, JSF was going to be used but we decided not to, so wondering if things that won't get used can be removed. (after reading comments I think removing JSF is not good idea though)
Java EE is a set of interfaces/annotations/etc for performing tons of different kinds of tasks commonly needed when building, well, 'Enterprise' applications. (the definition of which is its own multipage thread.) Glassfish is includes an implementation for each of the different APIs that make up JavaEE. Basically, when you use Glassfish, you can just go ahead and use anything in a 'javax ' package and it will be there for you, working. (although sometimes not the most performant or scalable implementation available...)
There are several options for java web containers that don't include implementations of the entire J2EE API built in. Tomcat and Jetty are probably the two most popular and widely used. Tomcat installs and integrates right into netbeans very well. But if you find yourself wanting to use something in most javax packages, you will need to provide an implementation, include the jar files yourself, etc.
--
Also, as an aside, the very, very nice Glassfish administration console (which is to me the chief motivator for using Glassfish) is done in JSF, so no, you can't really remove it :)
Regarding JavaEE, you don't need any jar file, but only a compliant application server, Glassfish in your case. And no, you can't remove features you don't need. But you don't have to use them if you don't want to... ;-)
In order to be J2EE certified there are certain requirements that must be met, and removing some of the functionality may cause problems.
For a nice discussion on what it means to be certified, you can start with this:
http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition
A Java EE application server can
handle transactions, security,
scalability, concurrency and
management of the components that are
deployed to it, in order to enable
developers to concentrate more on the
business logic of the components
rather than on infrastructure and
integration tasks.
If you find that you don't want to use much of J2EE you can look at something like the Spring framework (http://www.springsource.org/) which will offer more capabilities than just tomcat/jetty, but you can add/remove the parts you don't need, though you will need to include the core.
If you just need JAX-WS for example, then you can just add that manually, but, depending on your application you may find that there are many parts you will eventually need to make your life easier.
I have came from another question to this one:
How can one start with Java (JVM) ecosystem? What are beginner, intermediate and advanced knowledge-bases (bags!)? To be honest Java ecosystem was always a bit confusing to me, so it would be very helpful to provide some "reference references" and "defacto tutorials" for learning (curve!) JVM.
Note: I want to use JVM with Scala (or Clojure) but not Java itself.
I am a C# developer (WPF, Windows Forms, ASP.NET, Web Services, ... like that).
The Java Tutorial is a good place to start.
Update: you have enough questions for about a dozen posts here ;-) Honestly, you should do some research yourself (Google is your friend), then ask more specific, targeted questions; that would yield better results. (e.g. I don't think anyone can answer your question regarding Swing or JavaFX without more specific details about what you are trying to achieve.) I try to give a few pointers below, about areas I know to some extent.
for servlets and other web frameworks, here is a bunch of tutorials.
Tomcat and Jetty are both application servers.
there are a lot of different web frameworks, because different people have differing preferences, ideas and style, so many have created their own framework. It can be confusing, but at least there is choice :-)
for persistence, apart from JDBC, ORM frameworks are another strong option. I use Hibernate and I can recommend it; in a bigger project it can make your life much easier. Ultimately it depends on your specific project and constraints; there is no single right choice.
AFAIK Java has no equivalent of LINQ.
See also this post for further recommendations.
Java based web applications need to run inside of a web container such as Jetty or Tomcat.
You build your app and deploy it to the container which hosts the application at runtime.
Pure/plain JDBC should only be used directly by simple applications or integration layers that do not have access to the class model.
Most applications that I have seen have used some kind of Object Relational Mapping framework which models the entities as classes at a higher level than plain old JDBC.
Popular O/R frameworks include:
hibernate
toplink
datanucleus
cayenne
For web based development, you could start with AppFuse, see the quickstart guide.
AppFuse is a templating system that generates the skeleton of an application for you.
Then look deeper into what has been generated, and see what frameworks they are using.
AppFuse lets you choose between different technology stacks, so you could compare.
I haven't seen AppFuse support for Guice or GWT.
Guice is a Dependency Injection framework, others that could be used instead are Spring or picocontainer.
Another investigative approach that you could try would be starting with AndroMDA, which is a model driven architecture framework - you start with a UML model and then generate or forward engineer a working application.
AndroMDA also lets you control the choice of the underlying framework implementations by configuring different cartridges, once again you should dig deeper to see what they are using in the generated application.
If you are looking for a basic introduction, then the Java Tutorials are nice. To do other things like Java Web Development, then your going to need to consult google for the respective technology since they vary so widely.
One book though that I highly recommend taking a look at is Java Concurrency in Practice
Yeah, it is almost impossible for new guys to get started. This is going to drive away a lot of developers, and Java is in danger of not having constant new bloods. The old farts would love that, it's great for career security, and that's why they are making Java more and more complicated.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have some experience writing web applications in Java for class projects. My first project used Servlets and my second, the Stripes framework.
However, I feel that I am missing the greater picture of Java web development. I don't really understand the web.xml and context.xml files. I'm not sure what constitutes a Java EE application as opposed to a generic Java web application. I can't figure out how a bean is different from an ordinary Java class (POJO?) and how that differs from an Enterprise Java Bean (EJB). These are just the first few questions I could think of, but there are many more.
What is a good way to learn how Java web applications function from the top down rather than simply how to develop an application with a specific framework? (Is there a book for this sort of thing?) Ultimately, I would like to understand Java web applications well enough to write my own framework.
Update: To be clear, I am not interested in learning how to use specific frameworks (for instance, Spring or Java EE). I am looking for an explanation of the internals of a generic Java web application.
I recommend Head First Servlets and JSPs by Bates and Sierra. Some don't care for the whimsical style, but it is a solid intro to Java EE. EJB's aren't covered, but one book can't do everything.
I don't really understand the web.xml and context.xml files.
The web.xml file is just a configuration file which instructs the application server under each which filters/servlets to load and instantiate and on which url-patterns those should be invoked.
The context.xml is just another configuration file which instructs the application under each where the webapp is located at the local storage system and on which domain/URL context it should listen.
The appserver parses both files on startup and takes actions accordingly.
I'm not sure what constitutes a Java EE application as opposed to a generic Java web application.
It's unclear what your own definitions of "Java EE application" and "Generic Java Web application" are. To answer such a question (even though yourself), you'll need to lookup and/or redefine the definitions. But in general, there are two kinds of Java EE applications: web applications (usually to be deployed in flavor of WAR's) and enterprise applications (usually to be deployed in flavor of EAR's). The major difference is that the second involves EJB's and thus require to be run on an application which supports EJB's (e.g. Tomcat doesn't).
I can't figure out how a bean is different from an ordinary Java class (POJO?) and how that differs from an Enterprise Java Bean (EJB). These are just the first few questions I could think of, but there are many more.
Those are just terms which are been applied dependent on the purpose (and history) of the class in question. The term "POJO" is a (generally negative) term representing a Javabean which is just a value object (totally no business logic, pure bean with only getter/setter methods) and is generally a model object which is part of a "legacy" program which uses EJB/Hibernate. Some call it VO (Value Object), others call it DTO (Data Transfer Object), again others just stick to "javabeans".
What is a good way to learn how Java web applications function from the top down rather than simply how to develop an application with a specific framework? (Is there a book for this sort of thing?) Ultimately, I would like to understand Java web applications well enough to write my own framework.
Start with Head First Servlets & JSP. Read the Servlet API and try to implement one yourself. Knowledge of HTTP is however mandatory as well. Read/debug/play/hack the source of existing open source Servlet API implementations (e.g. Tomcat). Read/debug/play/hack the source of existing open source (MVC) frameworks (e.g. JSF). Try to understand how they works and then try to do it better. For the learning path ("What skills do I need?") I've posted a similar answer before here.
The best way to explore the Java world and to connect all the dot’s is to just use one of the frameworks, as all use web.xml, context.xml and Java EE components (all can persist the Pojo entity beans). As you already know the Stripes framework, I can recommend this book (it’s short an handles all the aspects you named):
Stripes: ...and Java Web Development Is Fun Again,
by Frederic Daoud,
Pragmatic Programmers,
ISBN: 1934356212
A more thoroughly approach for a deeper understanding of these Java EE technologies would be to gain all the knowledge necessary for passing these two Java Certification exams:
Sun Certified Web Component Developer (SCWCD)
Sun Certified Business Component Developer (SCBCD)
See the answers to this question.
Also, I build web apps with Java without using the traditional servlet-based approach at all. I generally use Restlet to build RESTful web apps which I run as standalone Java apps with embedded HTTP servers. This article details some of the advantages of using an embedded HTTP server instead of building a traditional Java web app and deploying it in a container / app server. If you're building a "regular" web application as opposed to a RESTful one (not necessary, IMHO), then check out Play, a cutting-edge high-level MVC web framework which allows for rapid development with much less ceremony.
Good luck!
If you're trying to get a good handle on what all of the bits are for in the Java EE spec and which of them you might use for web applications, I strongly suggest taking a look through the Java EE Tutorial. You can probably skip over the in-depth capabilities descriptions since you mostly want to get a high-level overview of each technology, its capabilities, and how it fits with everything else. However, do read through some of the examples that tie together the Web Tier, EJB's, and Persistence.
Get "Heads First Servlets and JSP" - it's a semi-weird looking book, but the content is excellent and people use it as a prep guide for the Sun Certified Web Component Development exam (SCWCD) for which the SCJP (Sun Certified Java Programmer) exam is a pre-requisite.
You should seriously consider getting both the SCJP and the SCWD, at least because you force yourself to get through the material. They won't guarantee to make you a better programmer than what you are now, but they will expose you to Java/Java EE material that is (usually) only available at the workplace.
I've also used some self-paced online courses with webucator.com, and I'd suggest you check their SCJP 5.0 and Web Services courses (the later similar but distinct from Web component development.)
There are frameworks out there that make Java EE web development less painful, but the more you know the guts of them, the greater your understanding of it will be (and you will be much better equipped to use it or its alternatives.)
Another book that you might want to check (perhaps you should check first) is Downey's Web Development with Java: Using Hibernate, Jsp and Servlets. It is out of print now, but there are used copies available for sale. Prof. Downey used this book to conduct a Java EE course at Florida Int. University covering the start and end of developing database-driven web applications. *
You should have some knowledge of SQL and relational database theory, even if you end up using OR mappers. This type of knowledge goes hand in hand with developing non-trivial web applications.
The irony is that the reason you want to know all about Java web development is the same reason that you are having so much trouble getting a handle on it. Why is it that every Java developer wants to write a web framework?
Seriously, though, there is an extremely long history to Java web development. From the beginning, there has been a fight between heavyweight and lightweight. It all started with EJBs and that they mostly sucked. The alternative to all that was struts. And that kind of sucked too. It all spiraled out from there with Spring bringing in the wave of dependency injection, then JSF was more complicated than ever. Finally, Rails showed up and just ran circles around everything Java had to offer. The current crop of Java frameworks show some of the legacy and battlescars of the previous generation, but it has gotten better. In general there's less configuration, and an attempt be leaner, with fewer dependencies and layers.
To answer your question more directly though, just look into the difference between a servlet container like tomcat, and a full Java EE application server like Glassfish or JBoss. It basically boils down to whether or not you want to use EJBs. If you plan on writing your own framework, you won't. Basically, just look at how servlets/servlet containers work. Beyond that, look at the source code of other frameworks.
What are the primary reasons for using the Java EE (EJBs) over just a simple Servlet implementation?
I am working on developing a new project that will primarily be a web service that must be very fast and scalable.
Sorry for any confusion, Although I am experienced in Java, I am very new to the Java Web world, and may not be asking this question well.
Servlets are HTTP request listeners; they can't respond to anything else.
If you embed a great deal of logic in servlets it won't be available to any other clients.
Write your app in POJOs. Get it thoroughly tested without an app server involved. Then worry about how you'd like to package and deploy it. Servlet? EJB? Web service? Something else? No problem - those are just packaging and deployment issues. Get the behavior that you want working properly in POJOs first.
Spring can give you a lot of options here. I'd recommend it.
EJB's specification 1.x and 2.x added complexity that for most webapps was not needed.
Due this complexities the new frameworks appeared to simplify the development and the runtime architecture ( Hibernate / Spring / other microcontainers / others ORM frameworks ) .
EJB's 3.x matches this changes ( through JDO and JPA ) and now, using Servlets with these enhanced frameworks or Java EE with EJB 3 + would give you basically the same results.
Using a Java EE Application Server would add you a number of administrative advantages ( GUI to manage pools, logs, monitoring, transactions etc. ) With out them you may have the same result but you would have to do it all by hand ( editing configuration files that is ) Which may not seem too problematic, but if you plan to have an administrator for your webapp It would be better to use the admin tools that come out of the box with this servers.
Is the web service stateless? If so, I don't see any real advantage in using a full blown Java EE server over something lightweight like Tomcat or Jetty. You can deploy a jax-ws implementation with either of those, and do what you need pretty easily. If there's some kind of state involved, and you end up wanting to share that across multiple machines, that is where having Java EE can come in handy.
With that said, I don't think Java EE would decrease performance any at all. The app servers generally take longer to boot, and take more effort to manage, but once they are up and running the performance should be similar.
If your web services are likely to need any degree of "enterprise" features such as per-method security or transactions use EJBs.
With EJB 3 this is not actually very hard at all, a couple of annotations and you're done.
Otherwise simple POJOs behind a servlet are enough.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'm looking to start developing for the web using Java - I have some basic Java knowledge, so that's not a problem, but I'm at a loss when it comes to deciphering the various technologies for use in web applications.
What options are available to me? How do they work? Are there any frameworks similar to Django/Ruby on Rails which I could use to simplify things?
Any links which could help with understanding what's available would be much appreciated.
Java frameworks come in two basic flavors. One is called the "Action" Framework, the other the "Component" Framework.
Action frameworks specialize on mapping HTTP requests to Java code (actions), and binding HTTP Requests to Java objects. Servlets is the most basic of the Action Frameworks, and is the basic upon all of the others are built.
Struts is the most popular Action framework, but I can't in good conscience recommend it to anyone. Struts 2 and Stripes are more modern, and very similar to each other. Both are light on the configuration and easy to use out of the box, providing very good binding functionality.
Component Frameworks focus on the UI and tend to promote a more event driven architecture based on high level UI components (buttons, list boxes, etc.). The frameworks tend to hide that actual HTTP request from the coder under several layers. They make developing the more advanced UIs much easier. .NET is a component framework for Windows. On Java, the popular component frameworks are JSF (a standard) and Wicket.
As a rule, if you're creating a "web site". that is something more akin to presenting information (like a blog, or a community site), the Action frameworks work better. These sites tend to be simpler, get bookmarked often, require "pretty URLs" etc. This is generally easier to do with an Action framework.
Component frameworks are much better for things like back office applications with lots of UI elements and complicated workflows. You'll find, particularly with tooling, that these style of apps will go together faster using a component framework. But component frameworks have more complicated request workflow, sometimes relying on hidden state, lots of POST actions, etc. Many have "horrible" URLs, and sometimes create pages that are difficult to bookmark.
Both frameworks can be used for both tasks, just some are more suited to the task than others.
None of these frameworks directly address persistence, but many have extension modules or idioms that work tightly with JPA/EJB3 or Hibernate.
Your basic java web technology is servlets. Servlets let you write Java code that responds to various HTTP events (doGet, doPost, doPut, etc). They're generally used for controllers in the MVC architecture.
Link: http://java.sun.com/products/servlet/
JSP lets you write HTML with embedded Java instead of the other way around (in servlets). JSP has been extended via JSF to incorporate more recent architectural advances. This is in the same line as PHP and ASP. This is the view portion of the MVC architecture.
Link: http://java.sun.com/developer/technicalArticles/GUI/JavaServerFaces/
A lot of more complex applications utilize Enterprise Java Beans (EJB) for session management, clustering, etc. This isn't a web technology, per se, but you see it go hand-in-hand when dealing with more complex webapps. Alternatives include frameworks such as Spring.
EJB: http://docs.jboss.org/ejb3/app-server/tutorial/
Spring: http://www.springframework.org/
Also, you'll want to familiarize yourself with ORM technology (after servlets and JSP/JSF). The leading ORM framework is currently Hibernate. This lets you map SQL tables to java objects and interact with them accordingly. This is more advanced stuff so save it for when you're trying to get your head around EJB/Spring, etc.
Link: http://www.hibernate.org/
edit: I forgot to define ORM. It stands for Object Relational Mapping/Mapper (whatever version of "Map" you feel like using :)
Start with JSP backed by logic in Java classes. Or use servlets.
The advantage of using JSP and Servlets is that you gain knowledge of what all the frameworks do under the hood. And that understanding is crucial to figure out how to do X in that particular framework.
Furthermore, JSP is very easy. You can easily see what you're doing and very easily see it when you mess up the view with business logic.
And quite a lot of frameworks (Struts, Spring MVC) use JSP as their view technology. It's a natural first step in web development using Java.
I don't know if there's anything quite as nice as Django for Java, but Spring has a light-weight web framework built on J2EE
http://www.springframework.org/about
A flexible MVC web application
framework, built on core Spring
functionality. This framework is
highly configurable via strategy
interfaces, and accommodates multiple
view technologies like JSP, Velocity,
Tiles, iText, and POI. Note that a
Spring middle tier can easily be
combined with a web tier based on any
other web MVC framework, like Struts,
WebWork, or Tapestry.
something like grails ?
there is also the projects from spring
You'll need to start with servlets and JSP. There are many web frameworks in Java and all of them are based on these two technologies.
You could try Jboss Seam : http://www.seamframework.org/Documentation/GettingStarted
If you are using Eclipe as your IDE there is good integration via Jboss Tools or you can use the Seam-Gen tool that comes with Seam. This allows you to define a database table (or tables) and with a few easy commands, build an entire runnable web project from it. It's a nice way to get the ball rolling.
Also Java Server Faces
http://en.wikipedia.org/wiki/Java_Server_Faces
This is a very open-ended question. The short answer is "yes" there are frameworks, libraries and standards to do everything from writing things at the HTTP request level up to content management systems in Java.
You can also use other languages (e.g. Python, Ruby, etc) on the JVM for that matter.
For some of the Java-only technologies, investigate JSP/Servlets, Struts, Struts2 (which is the updated version of Webwork), Spring MVC, Tapestry, web4j, Wicket.
There are other frameworks built on the JVM but use languages other than Java such as Grails.
To get started I would download Eclipse (latest version) and Tomcat. Create a new web application in Eclipse. There are guides that can get you started.
Start with learning how JSPs and Servlets work, these are a bit low level and aren't really a framework, but will let you get up and running quickly. From there investigate and choose your framework.
Spring MVC is pretty easy to get set up and going. I'm certain there are others.
If you already know Ruby On Rails, you can use it with JRuby and deploy to a Java server (like Tomcat) with Warbler.
In pure Java, Wicket has a good approach and is getting quite popular.
Before studying those frameworks, why not study first where it all started? Try programming with servlets first, so you could a peek at the core of most of those java web frameworks. It would help you understand J2EE better.
J2EE is the standard. You can use this to build apps with Java Server Pages, Servlets and EJBs.
Struts is also a very popular framework that uses JSPs and Servlets. Its a bit tricky to get setup but it is a very good option for mid size sites.
http://en.wikipedia.org/wiki/Struts
In general Java is more component-based, i.e. you don't have frameworks that do it all for you (you'll probably have to pick a database access framework yourself, for example). For Data Access I'd recommend Hibernate or iBATIS.
For the front-end there are literally hundreds of frameworks around. Investigate JSF, Wicket, Struts 2, Stripes - whichever one you use depends on your specific needs as they all have different strengths.
And for a business layer I'd recommend the Spring Framework, which is very comprehensive and has a great reference guide / tutorial :)
I learned Java in college back when it was in version 1.1.5. I recently started trying to program for the web, but it didn't make sense until I read Head First Servlets and JSP. There are way more things involved in web development with Java than I ever realized, and without this book, I would have quit and just used PHP.