Work on application and library simultaneously? - java

I'm new to java programming and I would like to work on some kind of game engine / lib. Just as a hobby project / experiment. I would like to make some sort of library with classes and utility functions to be able to re-use some generic game code and then a seperate application where I would build the actual game.
I am using intelliJ as an IDE. I was wondering if I could use, change and test a library with an application at the same time and how I would do this?

There are two aspects here. The technical: How does it work? The organisational: Is it a good idea?
The technical is quite easy. You just create different projects. The application project depends on the library project. Libraries are packaged as jars typically. Easiest would be to use a tool that supports you with dependencies and different versions of the library. I would recommend Maven for this.
The second question is harder and probably belongs to https://softwareengineering.stackexchange.com/ as it is more of a philosophical kind and no definitive answer exists. In my point of view it is a bad idea to develop a library and a product at the same time. Specificals of your product will slip into the library, you will get problems with priorities.
That is, when you are developing a library that should be used or published independently of your application. Modularisation of an application is another cup of tea, but could be done with the same tools. With Maven you would setup a multi module project then.

What do you mean by a library? A JAR right, a JAR contains a set of classes, what you would do is to "use, change and test" the classes you would like to make a library and when everything is done, you package it as a JAR and there you are done! If you want the JAR to be created everytime you "build" try using Maven or Ant that does these packaging tasks for you automatically. Maven is more powerful and you would love to see that it mainly does "dependency management" and your library is the dependency for your project.

Related

Gradle/Maven Java WebApp + Bower as separate modules in IntelliJ IDEA

I am working in a University project which involves developing a Java-based JSF WebApp. For the development I will be using IntelliJ IDEA and Maven or Gradle (at this point I don't care which one, any of them will fit).
I will also be using JavaScript in the project and I would like to manage its dependencies with Bower.
I could easily throw a js folder inside the webapp directory. I have seen many examples of this, but I do not like it as an approach.
What I want to do is separate the server side implementation from the UI implementation. So, I guess that means having two modules in IntelliJ IDEA, one containing all the Java-based server implementation and another one containing the static web files.
How can I accomplish this using IntelliJ IDEA and/or WebStorm if necessary? Actually, can it be done? Any suggestions welcome/appreciated.

Optimizing classes exported to an applet

I am relatively newbie in Java. While I was developing an applet, I made as well a library containing a series of functions to be used in a server side application.
I realized that perhaps I could shrink the jar size, by exporting only the classes, from the library, i am using inside the applet.
Is there any way to do it semi-automatic?
Some app that could point me the used classes, or something likewise...
EDIT :
Perhaps I could not express it right.
What I want to do is get which classes from this library of mine I am using for the applet.
I can do it manually, as I am doing it right now, but I would rather use a tool that would help me to create a build out of it, telling which classes I am working with, instead of a guess which I am using.
I am using eclipse, but I am aware of ant.
I am aware on how to build an applet, or a jar.
My problem is to make it more efficiently.
This greatly depends on the tool you are using for building the jar-Files. But probably those tools already have a mechanism in place to exclude classes / files from the jar-File.
A classic tool would be ant. If you are using ant, this link should provide information to you: How to exclude a directory from ant fileset, based on directories contents
If you are using a different tool, please edit your question.
On a sidenote: Are you really sure you want to use a Java Applet for a Client/Server Application. If you prefer an applet because you can distribute it easily, consider using Java Web Start.

Can Intellij IDEA exist in a Netbeans Shop?

All my other colleagues use Netbeans, but I have an opportunity to use IDEA. Will we be able to work on the same Java EE projects together, or will we have issues with projects, checking in and out of SVN, etc?
We primarily develop EE and Spring MVC applications using Glassfish on our desktops, and commit to an SVN, although it is possible that I may have to load a coworker's entire projec.
As long as you are using some standard, IDE-agnostic build tool like maven, I see no problems. I work on IntelliJ IDEA while my colleagues use Eclipse - no issues except different formatting rules or import order - all of this can be customized.
Subversion (or any other VCS) is the least of your problems. Even if the rest of your team pushes Netbeans project metadata files, IntelliJ will simply ignore them.
If you use Maven as your build tool, then yes (and Eclipse too).
All three have tooling allowing them to work well with Maven projects.
If you are using "plain" Netbeans projects I do not think that IDEA can work with them. If so, I suggest you lobby for the change. Maven is one of the investments that pay well of.
Why would you want to fly in the face of convention and be the only one on a different IDE? You'll waste time on issues that nobody else has, have formatting hiccups, struggle with pair programming etc.
As much as I like freedom of choice, the development environment within teams should be consistent.
I thought build tools like ant, maven or gradle are de-facto standart of java ee industry. Purpose your teammates to use it.
You will have issues with sharing projects, because the project folder and structure for Netbeans and IDEA is different.
However, you can attempt to share your src folders with one another and update your codes with one another through SVN, though I wouldn't advise it for compatibility reasons because you won't be able to properly share libraries and use other team functionality available in NetBeans.
So it won't be a good idea to use a different IDE so you don't waste time debugging compatibility.
Also, its useful to note that IDEA uses its own custom libraries for certain functionalities, and also build projects in a different way from NetBeans, so projects that appear to work on IDEA may not work on NetBeans and vice versa.
Bottom line, don't waste your time using a different IDE from the rest.

How to specify/organize/clean up jar libraries in projects well

When we develop a project, if we want to use struts or tiles or spring or anything else, we have to import some jaf files (into project build path or lib folder)
So I want to ask, is there any website/tool that specify which .jar files we need for each purpose so that I don't have to add a lot of jar files into my project
I'm sorry if this question is irrelevant. I just don't know where to ask :(
Nice day ^^
Use Maven. It is a build/dependency management tool which enables you not to download any dependencies manually, you just have to define it in a configuration file that you need a specific version of a library and it takes care of it all. Also you can use a number of so called archetypes which are basically skeleton applications for a specific set of technologies.
I do agree with abalogh
Use Maven or Ant & Ivy for your needs
When you turn into serious development, you can go without these tools. Test both and choose whichever is good for you. Don't listen to trolls about this or this technology (Mine is better ! No, it's Mine), go to websites, learn to use and make your choice. Then stick to it to get the best out the tool you choose
Cheers
Grooveek

Managing a Large OSGi Application

I have a large, growing OSGi application with a number of bundles. I am curious to know the best way to manage this type of application. Currently, I am using Eclipse and Maven, but although this is great for building bundles (via maven-bundle-plugin), as of now it has not been easy to manage the entire application.
What I would like to do is either have ONE run configuration or ONE pom.xml that can be launched and the entire application/project be built and launched. Also, I would like to have something that would be good for debugging.
I have heard of PAX Construct and have it installed in Eclipse, but so far it has been of little help (maybe I'm not using it correctly).
I am sure there are people out there with large OSGi applications that are being managed correctly. Any advice that could be shared would help tremendously.
Thank you,
Stephen
A run configuration is possible via Pax Runner. It lets you choose OSGi platform implementation, specify profiles (pre-packaged sets of bundles for some role, e.g. web, log, ds, etc.) and has good provisioning support, for instance it can load bundles from Maven repository. As a result, you can have a run configuration like
--platform=felix
--log=INFO
--profiles=scalamodules,ds,config,log
mvn:com.my/bundle/1.0.1-SNAPSHOT#update
# other bundles
In case your application is very large or you have different applications, there a way to create own profiles as well.
Well...
It all deopends on what do You mean by "managing" the application.
For dev time launching, building and debugging - Eclipse IDE should fit the bill just perfectly.
Maven... I can't speak for it, as I've never used it myself.
We have a pretty large eclipse based application (several, actually) and on the dev side of things we are not using anything special besides the Eclipse and it's integrated SCM.
In the cc build server, we also use headless eclipse to do the building and packaging.
Now the setup of the workspace has gone a bit out of hand of late with all the dependencies and intermediate build steps, so we are investigating Buckminster for managing the materialization of target platform and workspace resources.
If that works out, we'll probably move to building with Bucky as well - it sure looks promising.
(I do not have any experience with PAX, but at a glance, it looks promising as well...)
i'm quite new to OSGi but,
wouldn't it be possible to use OBR-service in such a way that
you would have one OBR repository file which needs the bundles
and let the OBR-service figure out the dependencies and populate your OSGIhost for you?
This area I think has very poor support at the moment. OSGI doesn't really define anything about deployment or packaging so its up to other frameworks (e.g. Eclipse) to come up with their own way of doing it.
If you are building an RCP (Eclipse base) application, then the eclipse systems do all this stuff, right down to creating exes etc. However builds are mainly done on the Eclipse workspace, headless builds are trickier. The Tycho project is trying to make this more sensible by joining the Maven and Eclipse build cycles, however it is still focussed on RCP applications rather than generic OSGI.
If you not doing RCP, which is my situation as well, then you probably have to roll your own solution, as I haven't found any general solution. Here's an outline of what we do:
We define one POM project that lists all the bundles that are contained in your application. All this project does is list the references - lets call it the 'bundle-list' project.
Then, we use pax provision to run the project in development mode. This is achieved by making the 'bundle-list' pom the parent of the provisioning pom of the pax project (usually in the 'provision' folder). Then, when you start pax, it uses the list of bundles from that project to start OSGI. The bundle references in the 'bundle-list' project have to be marked as 'provided' scope for this to work.
Then, to create a distribution, we have another project. This project also has the 'bundle-list' project as its parent. This project uses various plugins to create a distribution, including downloading the bundle jars. The distribution includes scripts that start up OSGI, but these are hand written, there's no pax systems here.
This works well for us to keep the list of bundles in one place, but there's still a lot of hand written scripts, and there are issues sharing configuration between the two systems - e.g. config files, bundle start levels etc.

Categories

Resources