I want to get started with Java! I have a bit of experience with C/C++ and Python development. For this i'm mainly using Emacs (a text editor) and the commandline, thus not using a heavier weight IDE for those kind of things.
I don't want to adapt my workflow to suit an IDE, but I don't know the Workflow (write, build, test) in Java so I thought about asking here. Searching the Web didn't give me good results.
Can someone give me the the basic workflow when developing Java with my requirements? I use Linux for all my programming.
Are my requirements/wishes even practical or should i consider using something like IDEA or Eclipse?
Can someone point me to documentation or blog posts about this topic or documents, that give a quick overview and/or examples on how to get started with Java (something for programmers with a little experience in other languages)?
For this I'm mainly using Emacs (a text editor) and the commandline,
thus not using a heavier weight IDE for those kind of things.
An IDE has many advantages over a text editor, mainly when navigating, debugging and refactoring code, but it is not required. Actually, working without an IDE is useful to understand the underlying technologies. My advice would be: Start without an IDE, and when everything works, try out some IDEs to see how they help you.
Can someone give me the the basic workflow when developing Java with
my requirements?
The basic workflow is (for any compiled language):
write source code
build
run
In the case of Java, that means:
1 Writing source code
You write .java files in a text editor, observing the right filesystem layout (file name = class name, directory corresponds to package etc.). You already have that covered.
2 Compiling the code
You compile the code using a Java compiler, possibly building a JAR or WAR file (depending on the type of application you are writing). You can do that manually by directly invoking javac (see for example Java - compile from command line - external jar ), but you should really use a build tool. The best tool to get started is probably Apache Maven or Gradle.
The basic idea is the same with both Maven and Gradle: You write a build file, which essentially describes your project and how to compile it (a POM file in the case of Maven, a build.xml for Gradle), then you can build by just invoking the build tool. The build tool takes care of all the nitty gritty like invoking javac etc. Most importantly, both also perform dependency resolution, meaning they can automatically download and use libraries that you use in your code.
3 Running
Finally, you run the program from the command line. How to do that depends on the type of program: A simple executable (or a Spring Boot application) can by run using java -jar myprog.jar, a WAR file must be deployed to a Servlet container (such as Apache Tomcat).
I hope this gives a general overview of How do I develop without an IDE?. For more details, look for specific questions here on Stackoverflow (or elsewhere), read the docs, and if all fails ask a more specific question here :-).
I agree with #sleske : if you really want to learn the language, it's good to start with a text editor. Later on you can use an IDE but by then you will know how the build process works and what exactly the IDE is doing. There exists no magic in coding. If something works but you don't understand why, it will certainly fail one day :)
Maybe some nice feature: I use Eclipse and added a vim plugin :)
And if you learn some useful shortcuts you can write code really fast (without a mouse)
You should download IntelliJ directly:
certain best practices like static import make your code more readable because you read it with a smart IDE. If you read code just with vim, the navigation between classes is not possible.
you have an easy access to a terminal and perform certain Maven or Gradle commands here.
I would not say the same with other languages (css, html).
Related
I'm writing some Java code in vim and really miss the feature afforded by the IDEs such that I can type up a block of code, and after a few keystrokes have the IDE infer which imports it should place at the top of my file based on the classes I've used in my code.
Anyone know of a way to achieve this functionality in vim? I'm thinking a command-line tool I can shell to for the file being edited. The tool would ideally dump the imports to the screen after it's analysed my Java file.
You can try these links
http://vim.wikia.com/wiki/Add_Java_import_statements_automatically
Vim & Java: add java import statements automatically
Haven't tried it myself but its a good start.
It seems to boil down to two different approaches, ones like Amir suggested where some process generates a mapping file from classes on the file system, or the approach I ended up taking where the plugin communicates real-time to a process that does the heavy lifting (Eclipse).
So I chose Eclim, seems antithetical to vim's light weight mantra, but in the end was the best featured approach.
I've had several classes - university level - on Java.
However, what these classes lack is some practical approach to Java - or, to programming as a whole. Things you can only learn in a business.
However, since I am not allowed to use Java on the workfloor, I don't get to learn this now - even though I would like to.
So I guess what I'm asking for is any number of plain have-to-know Java resources. Things concering, for example, what Ant is and why and how to use it; using revision control systems from your IDE; standard Java libraries you would use often ... Anything that would help with actual software development, really.
As some side information, I've been using Eclipse for about four years now, and I feel at home there.
I have a system that works fairly well for class assignments and for projects as well. Firstly, I create one Eclipse project per class. This way I can re-use classes from previous assignments. You can also customize your classpath by adding another project as a library.
I use the Maven plugin for Eclipse M2Eclipse. Not only does this give you the ability to search for libraries and add them easily but the exec:java plugin is an easy way to execute your code from the command line. It's helpful because when it executes your code, it uses a classpath that includes all linked Maven dependencies. If you aren't using external libraries, you might not need Maven but I've found it to be helpful to learn in preparation for the job market. It's fairly simple to start with plus there are a ton useful plugins for open source projects.
Next, for revision control I recommend Subclipse. You can get a free SVN account with a single login from Unfuddle.com. Link that up to your Eclipse environment and Import your project.
When I want to get a particular class specification, I go to Sun's Java documentation.
Another excellent resource that will certainly give you the reference material (searchable!) to answer any java question would be this torrent containing ~100 ebooks on Java, sorted by directory on various topics (like Ant, Eclipse, or Swing).
I have to develop a small applet using, of course, java. I am absolutely ignorant about java and the java world. I dont' have the time to learn java "the programming course way". I just need to hack together this thing and then I won't code in java anymore (I assume).
My question is relative to the following subquestions:
is it feasible to code in java without eclipse, maven, etc ? I am pretty sure it is possible, technically, but is it really convenient/practically possible ?
how is the typical build/shipping process for java applets, in particular considering the presence of dependencies ? At the moment I am doing "screaming for vendetta" approach: download the dependencies jars, unpacking them, compiling my own .java file with the applet, repacking everything as .jar, copying it onto the web. I am pretty sure this is not the way to go, but it worked... at least for now. Clearly, I cannot continue this way.
I know Eclipse to be a behemot. how is the chance that I can produce something that works as in my current caveman approach within a couple of days ?
anything else that you deem important
Thanks.
Is it feasible to code in java without
eclipse, maven, etc ? I am pretty sure
it is possible, technically, but is it
really convenient/practically possible
?
Absolutely, you can write code in any text editor, compile with the javac command, and execute with the java command. It's not quite convenient, and Eclipse continuously loops a the build cycle for you.
I know Eclipse to be a behemot. how is the chance that I can produce something that works as in my current caveman approach within a couple of days ?
It's possible you'll be fine, but a little time with a real IDE will start increasing your productivity almost exponentially. To start, you'd be gaining intelligent code navigation, syntax validation, real-time debugging, refactoring support, and of course code completion.
Regarding your first point... yes, it is feasible to code outside an IDE in Java. a copy of your favorite text editor, the javadoc html pages and Ant will do just fine.
That said, you will be more productive in an IDE with Java.
"Back in the day", Eclipse and Netbeans were buggy and no other IDEs were free. So, plenty of people wrote lots of Java code (including me, and including my first applet) without the use of an IDE. You just switch back and forth between your command prompt where you would run javac and your editor-of-choice where you would make changes.
Likewise, build management tools like Ant and Maven are nice for large projects with nontrivial dependencies, but you certainly don't need them to write "Hello, world!" or even a "Hello, world!" applet.
That being said, I don't see any reason not to use an IDE today. They provide plenty of nice features that others here have already mentioned, which can save you from thousands of unnecessary keystrokes and dozens of careless bugs.
Developing without Eclipse or any other IDE (maven is a different kind of beast) is entirely feasible, but not recommended if you are ignorant about the Java world and want to finish everything within a couple of days. So, I suggest that you go with Eclipse. Download the basic Java edition, which is suitable for applet development. Among other things it will allow you to run your applet in an applet viewer (without having to start a browser). This is very convenient for debugging.
About the dependencies, you could create a "fat jar", with everything in it. A plug-in can help you with this. The other solution will be to place the dependencies in a "lib" folder. Then, in your applet jar, you need to edit the manifest file to correctly set the classpath. This is usually done with an Ant target.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Can anyone recommend a light Java IDE that doesn't require you to make new projects each time you want to compile and run a program? I just want to be able to open java files and compile and run them. I have already tried Eclipse and NetBeans but both require you to make a new project each time you want to compile and run a program. Making a new project is fine for large scale projects but for small school assignments this just makes the process more tedious.
I've been doing java school assignments using Eclipse. I had one project called "Homework", and created a new package for each assignment. That worked fine for me.
Update: in addition to the practice suggested above, it seems eclipse has a subproject (still in incubation, though) called ide4edu that is specifically for educational purposes.
The Eclipse IDE for Education is a version of Eclipse streamlined specifically for use by university and college students.
In Eclipse, you can just paste code into the package explorer without a given project, and a new project is created containing a file with that code, inside a main method. If the text you paste is a full class, it will name the file according to the class name. You could also set up a single project for your stuff and paste the code or the files you want to run into that project.
I've used Notepad++ to do this for simple Java projects and it worked quite well. Here is a guide on how to do this.
You may also want to check out jEdit, I believe it offers similar functionality, and may be more feature-rich for Java than Notepad++ is.
My school uses DrJava for the first intro to programming class. Its a lightweight IDE and allows you to create folders on the fly for your java classes.
However, my classes now require Eclipse or Netbeans, and it did take some getting used to them. In some places, Eclipse is overkill for a second-year CS student, but I do like its features & am having fun exploring the extensability with other languages.
It might sound geeky or "not for novices" but in order to compile and run a single file the best option(in my opinion) is a console environment.And of course you can view them from notepad++ or any editor with similar fetures(especially highlighting).
How about using a editor like Vim, or Emacs and then install some plugins so that you can have basic IDE features like code completion, etc? You will need to do bit of monkeying to get the right kind of combination and comfort. But, it could well be your answer for a lightweight IDE, one that does not require you to create a project.
NetBeans can have an arbitrary number of classes with main() methods. Create a project named school using NetBeans and create a new package for each group of related assignments. Customize the default configuration menu to make F6 run your current main(). At the same time, develop your skill with bash and a favorite command line editor.
Some universities (like mine) use
BlueJ
for Java Teaching. It basically got everything you need for your homework assignments, and it got NO code completion, which I find perfect for Java beginners ^^.
What's wrong with creating project? Just create it ones and then use it for all your assignments. That will let you use any good IDE (NetBeans, Eclipse, Intellij Idea, ...) which, from other side, greately simplifies writing java code.
I recommend bash. I write a lot of test programs for work (and for the likes of answering stackoverflow questions). javac MyMain.java && java MyMain and you are done.
I have done one project and many unrelated packages, but that sucks. It also cannot cope with more complicated build cases (when dealing with, for instance, serialisation or class loaders).
Personally I enjoy using Emacs for editing my code than then Ant to build / compile my Java code.
Bare in mind that using a lightweight editor will generally mean loosing out on some very useful features, for example:
Auto completion. So for example in Eclipse if you start typing System.out. you can a list of options to complete the statement along with which parameters the function will require
Mistake highlighting : nice "red swiggly lines" highlighting simple mistakes
Build path management : adding external archives is trivial in eclipse less so from the command line for those with little experience
Amongst many others.
Personally I'd way up whether the "faff" of setting up a new project for a simple Java application is worth loosing those really useful features. And that usually varies per task.
I recommend jGRASP. It's a (very) lightweight Java editor, good for the beginning programmer. You can literally paste in some code, compile and save, and your program is ready to be run.
You need a well defined classpath before you can just compile you classes, and that's exactly what the project setup is for.
Just create a project once and forget about it - use it for all your stuff.
you can use cedit. which is not exactly a IDE but you can have compiler and JVM tools attatched to it and you can do whatever you have mentioned. i mean creating a small java file compile and run.
you can that here http://mac.softpedia.com/get/Word-Processing/CEdit.shtml
Why don't you create one project and fill it with all the programs you ever write. There is nothing forcing you to create a new project each time. The only reason to have multiple projects is to make managing the programs easier. So if projects don't make your life easier don't create multiple projects.
BTW: I suggest IntelliJ as I believe it is better, but in this case I suggest the problem is how you work and changing IDE won't make much difference.
This sounds redundant, but the posters are right. However, you know what you can run. If you don't have the resources and you need to run a webserver, putty, etc.. notepad ++ would work (light enough). If your desktop is nice and can handle it, use Eclipse (vast adoption). Create a java project and add packages to it (as Kaleb, Frank and other suggested).
To use IDE for assignment, my approach is to create a test project and use it each time for different assignments. Because in IDE like Netbeans and Eclipse, each class file can be made executable, thus it is quite convenient acutally.
Also for assignments if you want to have more control over your code, Notepad++ is very good for writing codes. You can add in features such as Compile and Run using macros in Notepad and make shortcut key for it.
VIM and Emacs can also be good choices as my friend often talk with me about them. Well i am not quite familiar, you can try it.
I love vim, but not having things like IntelliSense/Code completion from Eclipse makes it pretty difficult. I know, I know, I should be able to look at method signatures and java docs for the API I am interested in using. I'd love to, but I'd like it to be accessible from my fingertips instead of having to browse the source tree manually or have a JDK reference handy.
What plugins would make this easier?
I tried eclim for a while. It was pretty good, basically it uses eclipse in the background as a kind of engine and provides a plugin to let you use all of eclipses goodness through vim.
http://eclim.org/
Don't write Java in Vim — put Vim inside a Java IDE:
IdeaVIM for IntelliJ
viPlugin or Eclim for Eclipse
jVi or ViEx for NetBeans
I love Vim, but using an IDE for Java is the only way to stay sane. A decent Java IDE will:
Show invalid syntax or type errors
Show missing JavaDoc
Manage import statements for you
Highlight unused methods and variables
Safely perform powerful refactorings such as moving methods or renaming classes -- (no, search and replace doesn't cut it, I promise)
Reformat your code automatically or on-demand
Vim can't do the above, but you can use all the Vim keybindings in a program which does.
I use Eclipse + Vrapper. Enables the vi dual mode editing we all know and love. <ESC>
Completely free and lightweight. The goal is to have the comfort and ease which comes with the different modes, complex commands and count/operator/motion combinations which are the key features behind editing with Vim, while preserving the powerful features of the different Eclipse text editors, like code generation and refactoring.
While eclim is another alternative, I feel eclim takes over Eclipse and vrapper doesn't.
Check out the JDE plugin for Vim. It provides Java omni-completion and a documentation viewer (among other things).
I use the javacomplete.vim plugin for omni-completion for java. It's a very nice script: it also shows the method signatures on top of the omni-completion. The downside is that it is a bit slow, but it has worked fine for me otherwise. Eclim might be better ut I haven't tried it yet so I can't comment on it.
I've also used the jcommenter.vim plugin for generating javadoc comments. It can parse method signatures and automatically add the relevant #param foo fields and such.
For the API searching I would suggest on overriding the K key on normal mode. It searches man pages for the keyword under the cursor, but the behavior can be overriden by setting the keywordprg variable. See this thread for an example.
Other scripts which I've found very useful (not specific to Java development): NERDCommenter, AutoClose, snipMate, Align.
There's an IntelliJ VIM plugin as well. Plus, IntelliJ is released an open-source, free version.
Vim is not an IDE replacement. But very specific additional tool. With Vim you should only do small-fast tweaks while the main development is going under Netbeans/Eclipse/IDEA.
One more time. It is a Bad Bad Bad idea to turn Vim into Full IDE. Why? It won't be so fast. And thus won't be so pretty.
Here is scenario. You have opened Eclipse or whatever to edit your current task. And in 10 minutes you have to switch to another Task which is kind of urgent. The task is to tweak a little a maven or an ant built script and/or some deployment perl/python/groovy scripts.
How much time will it take to reload Eclipse to work on a new 5 minutes task and switch back?
But if you are Vim guru you can handle this in seconds. You can change one file and run Ant/Mvn within Vim.
And this is the power of Vim. You can change and check one file in no time no matter which extension it has: java, groovy, c++, makefile, bash, c#, etc.
This will be an uphill battle. There is so much knowledge about your program built into Eclipse, that I expect you will eventually have to reimplement it all to be happy.
Any particular reason you cannot just decide you like the built-in editor in Eclipse?