問題描述
Ruby/Rails 開發人員的 JSP 工具? (JSP tools for a Ruby/Rails developer?)
I am a full time rubyist, really enjoying rails, Sinatra, etc. Currently, however, I find myself working on a Java/TomCat/JSP project.
I was hoping someone could help me find tools, articles, books, and any other resources that will make me more comfortable?
I'm aware that Java is very different from Ruby, and the communities, likewise, are very different. That being said, all of the documentation around Java (that I have found) is a mess, and discovery is very difficult in this community.
Things I'm specifically looking for:
- development environment setup tips
- logger, logging, colorful output, best practice, etc
- library resources and documentation
- easy to navigate documentation for Java SE 6
- anything you have found that makes your daily life better
Thanks!
‑‑‑‑‑
參考解法
方法 1:
If you are joining an existing Java project then you probably want to take a look at the tools already in use and get an existing developer / co‑worker to bring you up to speed with them as a first port of call.
Having said that, here are my top tips:
- Get comfortable with one of the main Java IDEs. Eclipse (my personal choice), Netbeans or IntelliJ are all excellent and very powerful tools once you get to know them. The refactoring / code navigation tools are probably better than anything you are used to in the Ruby world, they will help you a lot. Java is a lot less painful with a good IDE setup.
- Learn Maven ‑ this will take some time investment but it is extremely powerful for automating your dependency management and build process. Once you get it working you will save a huge amount of time on project / build management. Maven also provides automated access to the equivalent of Ruby gems through the various public Maven repositories.
And here are some particularly useful resources:
- Java tutorials ‑ good to get an introductory feel for the core Java libraries.
- Java 6 API ‑ useful as a reference resource for all the classes and functionality available in core Java (a lot of this is also provided via the IDEs)
- JSP Documentation ‑ for the JSP / Java EE aspects
方法 2:
As a little side note don't forget to learn about JSTL and Expression Language.
方法 3:
first of all you are on the right road to discover how elegant Java EE is. since you adressed various topics i will divide my answer into different parts :
- Development environment: Without further talk i will advise you to directly go and pick your eclipse Java EE Juno (last release) version, however if you'd like to have a look at other IDEs you can either check NetBeans 7.2 (last release) or IntelliJIDEA 11.2 Ultimate (last release i know of and that I have). Basically Eclipse has tons of plugins and features and backed up by a very great, large and passionate community.
[ i personally tried NetBeans, and IntellijIDEA, but felt more comfortable with Eclipse because of its look, features, cool color theme etc]
For JSP and HTML, CSS ,JS stuff, i however recommend the great IDE of Jetbrains Webstorm it has zen coding as well as many many other things like fast auto completion and support for many frameworks.
Lastly, pick up Sublime Text 2 as a text editor for quick edits or to just check a source file, it has a very beautiful layout and support for many languages as well as tons of plugins.
- Ressources and documentations :
All the Java API specifications are available for offline viewing for free in Oracle's website and come packaged with the various SDK that are available there.
The easy to navigate documentation : Eclipse IDE makes it very easy to attach JavaDoc and Source to the different jar files that make up a JDK, that said, your learning and coding experience will be greatly increased once you've set that up.So when you type Connection for example in IDE, you can simple hold Ctrl command then right click on it and the source code of the class implementation would be opened in a different tab. yes yes it's the power of the open source world :)
Concerning tips and tricks : I'll recommend you use //TODO comments as Eclipse has support for them and you can setup your own TODO comments in settings, also you can use TASK comments, you've Mylyn too to manage your bugs, tasks either locally or connect to your favorite bug and issue tracker through a connector since many connectors are available for such purpose. Add to this list the possibility to configure bookmarks to help you manage your source files when they become full of lines.
About Tomcat: Well if your goal is to make Java EE applications that do not require the advanced features of the Java EE specification, then you can use the sweet Tomcat, it's easy to use and configure and a well known web container.
However if that's not the case, and you wanna specialize in Java and spend lots of time to try to understand the ins and outs of this huge specification, you are likely to need a certified Application Server that supports all Java EE components. There are lot of them available, but since you asked for advise and I am here giving my modest suggestions I would advise you to pick the GlassFish Application Server, it's Open Source, and once you install it on Eclipse IDE for example, it will be bundled with both Java EE 5 and Java EE 6 API doc. This means no time to be wasted on browsing different tools and tabs, you will have everything grouped inside your Eclipse IDE so that you are 100% on the tasks at hand.
p.s: if you've any more questions please feel free to ping me.
- Any good tip or trick : Have fun with Java, because you will be learning everyday something new :)
p.s: i didn't mention any framework, because by the time you get used to Java EE you will be in position to pick the one that suits your needs. Also forgot to mention JUnit (Testing Framework) and a great eclipse plugin EClemma for code coverage (much better than Cobertura/eCobertura and easier to use), and of course you can try Maven as the other post mentioned, or try Apache Ant as build tool.
方法 4:
If you're coming from a Rails background, I'd be prepared for some initial frustration. Setting up projects in an IDE can be time consuming, and generally it's going to be more painful to get things like a basic web+app server up and running using Tomcat than using Ruby.
For a REPL, I would recommend Groovy (and indeed it comes pre‑installed on Intellij) but you can also use BeanShell. Grails, or groovy on rails, is probably the closest thing we have to a Rails‑like environment.
As others have said, with Java, using an IDE is really best. I like Intellij IDEA, but eclipse and NetBeans are also good.
For build and dependency management, Maven is probably as close as we have to standard, although I have heard nice things about Gradle.
There are entirely too many logging frameworks in java, use whatever your project currently uses, probably log4j or SLF4J. learn how to change log levels across the board, and also at a package level.
In terms of libraries, Google's Guava makes my life better on a daily basis. The best "tips, tricks and general best practices" book on java is Josh Bloch's Effective Java. For documentation, the Javadoc is the authoritative source. Learn to read and write good javadocs.
For Test Driven Development, jUnit is probably the most widely used library, a very popular library is mockito, which also happens to be my favorite.
(by andrewpthorp、mikera、Bmud Eht Yug、gaspyr、Paul Sanwald)