Can OpenCms be integrated, or used, with an IDE? - java

I'm starting with a new project where we'll be using OpenCms. Can the workplace be integrated to an IDE, and which one is it ?

Also if you are planning to use Eclipse OpenCms module with OpenCms 8, I am afraid you have to use the WebDAV Eclipse plugin with OpenCms, the other plugin stop working.
Link to the wiki reference page.
So once you may set:
Create a blank new module on your OpenCms.
Create a standard Java project.
Change the project setup to create the class files under a folder called "classes" instead of bin.
Import the module through WebDAV into the new module.
Create an user library with all the jars placed under the lib/ folder located in the OpenCms deployed war and add it to the buildpath.
Now you are ready to go.

If you're just going to develop on your local machine, I'd recommend the OpenCms Module Developer for Eclipse. The only thing you have to be aware of, is setting the encoding of the files to the same (by default Eclipse has some ISO-9... for editors which can be changed in the preferences).
Otherwise you could utilize the webdav-access to the VFS to edit with your favorite Editor.
The OpenCms Wiki might help as well in general.

This should help if you use Maven (which you can use with Eclipse):
Fully automated builds with the OpenCms-Maven-Plugin:
OpenCms-Maven is an open source
project ... to ease the build and
versioning process of OpenCms
projects. The core of the project is a
Maven plugin that enables full
automated OpenCms builds and provides
functionality to synchronize virtual
file system resources of OpenCms with
a real file system.

here is the link on the wiki that works...
http://www.opencms-wiki.org/wiki/Main_Page

Related

Where to place java packages like htmlparser?

I am beginning to use java packages like HTMLParser, I have downloaded it and finding that there are many files and directories in it.
I wander, where to place them in my linux system? Is there a convention or a standard?
The quick and dirty answer is "anywhere on the classpath", where the classpath is set either as a system property on the client machine (not recommended), as a temporary system property for the CLI session used to start the JVM (workable from a startup script), or as a commandline parameter to the JVM (usually the preferred choice).
First and second set the CLASSPATH environment variable, see the JDK or JRE documentation for the exact syntax and your operating system's and/or shell scripting documentation as well. Third uses the -cp commandline variable to the Java runtime and compiler, see their documentation for exact syntax.
Where to place the files on the filesystem? For development purposes I typically use a central folder on my computer containing all such libraries and link to that from my IDE or other development environment. For deployment/packaging to end users, it is traditional to have a "lib" subfolder to the product folder that contains all distributable content, and put the jar files in that.
Java packages come in two forms. Source code - all the files and directories you mention - and packaged as jars. A common convention in Java projects is that the project has a lib directory that contains all the jars that the project depends on. These projects often use a shell script which adds all the jars to the Java classpath prior to executing the project code.
However many projects are switching from this method of dealing with dependencies to using a build tool like Apache Maven which automatically handles dependency management. Other alternatives include Ivy or Gradle. For an introduction see the 5 minute introduction to Maven or the Maven 3 tutorial.
Here you write a pom.xml (project object model file) which specifies which libraries (jars) your project uses. Maven then stores all the jars for your different projects in a .m2 directory in your local directory, keeping track of where it obtained them, and their versioning information.
This makes developing much easier as you do not need to create the lib directory or manually manage dependencies. You also avoid a lot of the complexities of setting the classpath, as Maven automatically does this for you during common lifecyle stages such as compilation and test. Recent versions of Eclipse can read the Maven pom and automatically configure your classpath from it.
Once you have built the project, Maven can also help create "fat jars" that contain all the jars your project depends on, via the assembly plugin or the Shade plugin. This makes distributing the code easier when you are building an executable that you want someone to use. If you are distributing a jar, then your pom.xml describes the dependencies of your project, avoiding the need to distribute the jars it depends on.
For laying out files in general on a Linux system consult the Linux Filesystem hierarchy standard.

How to create an executable version of my OSGi project?

Is it possible to save my OSGi project (which comprises of few bundles) to a single executable file, something like an .exe file , so I can copy and run it to any PC that has a JVM.
I know that the normal method is to open a command prompt and install the required bundles/ jar files one by one. But since my project contains quite a few bundles that method seems tedious.
Thanx in Advance.
You can definitely do better than installing bundles one by one, even if you don't get as far as a single 'natively executable' archive like a .exe. There are lots of commercial and open source OSGi applications which ship as zip archives; the user unzips the archive and then either calls java -jar some.osgi.jar or runs a shell script.
There are a few ways the OSGi runtime can work out what bundles to install. Some are specific to an OSGi framework (such as Equinox or Felix) and others are more generic. If you're using Equinox, you can create a config.ini file and put it in a folder called configuration as the same level as your OSGi jar. List any bundles you want to start in the osgi.bundles property. The config.ini file can list all the bundles to start, and also any other configuration properties you might need.
Eclipse also allows you to define a minimal set of bundles in config.ini and use the configurator to start everything in the plugins folder. Similarly, if you're using Felix, any bundles in the auto-deploy directory will be automatically started. You could also look at Felix File Install, which allows you to drop bundles into a monitored folder to install them (once FileInstall itself is installed). Despite the name, FileInstall works on both Equinox and Felix.
This is similar to creating a complete OSGi application with Felix & Maven - the Sling Launchpad Plugin can be used to create an executable jar or war file that contains a specific set of bundles. If you're not using Maven yet it's not as simple as "saving your project to an executable file" but you could probably adapt the jar file generation mechanisms to your environment.
Eclipse has the notion of products. You could create a product from your existing bundles, and then your product can be exported as an executable. For details about the product see the Eclipse RCP tutorial from http://www.vogella.com/articles/EclipseRCP/article.html
The tutorial introduces the Eclipse RCP applications, but you do not need everything from there - it is possible to create a product without creating an entire Eclipse application.
This limits your choices as you are more or less bound to Eclipse Equinox as your OSGi runtime, but for creating an executable product from it might be a workable tradeoff.
Thanx.
Following the answers above I came across Chapter 9 in this book.
http://my.safaribooksonline.com/9780321561510/ch09#ch09
It had a walk through tutorial in exporting the project through the product configuration.
Its exactly what I needed. :)
If you use bnd(tools) then you can export a project to an executable jar either from the bndtools GUI or via the bnd commandline (bnd package xyz.bndrun; java -jar xyz.jar). The resulting jar file contains all the bundles, the launcher, and the framework.

How to add source files of library jars?

I am using Eclipse IDE and its derivative like Spring IDE for Java development.
In a web application project, I add external jars like Spring MVC jars, Apache commons jars etc to the Web App library folder, hence they are automatically added to the build path. There are many jars in the Web App library folder.
I want to create folder in the project and add all the source files (zip/jar) of the libraries included in Web App library folder, so that I can navigate through the source of libraries from the Java editor window. Whenever I add a source zip/jar file to this folder, Eclipse should detect it and use it whenever I want to navigate to the source of a library.
Is the above possible in eclipse?
Note: I know how to add source files
for each individual jar by navigating
to the build path window and
specifying the source location. But
this is very crude way, and I need to
do for every library individually.
Also the drawback is that source path
is absolute, which means if I import
the project into another computer then
I need to create the source path or
even worse I might have to add the
source files individually again.
One way to automagically get the sources for the jars would be some kind of dependency management system. Most people would scream Maven (2/3) by now, but others exist and work well. Maven does have nice Eclipse integration, so that should be a plus.
The downside is that setting up a Maven project just for it's dependency management can seem overkill. Another point is that all the jars you depend on should be "Mavenized" as well.
As far as I know Eclipse wont automatically detect/scan source archive files and link them up to libraries in your workspace in the way you described it.
I agree with #Gressie on using Maven and the Eclipse Maven plugins -- as in that case it's just a matter of ticking a few boxes and Maven will do that for you.
If however your project is not Maven-ized, you can still do this in Eclipse but it's more tedious:
for each one of the jars in your project (which appear under the dependecies section) right click on it and select properties
in the dialog that pops up you have (at least) 2 locations you can configure: java source attachment -- simply browse to your jar with the sources -- and also javadoc location (point it to the jar with javadoc if you want the javadoc to appear as a tooltip when you hover the mouse over one of the classes/methods/etc in that library).

add library to seam project

How can I add an library to a seam project?
Do I need to copy them manually somewhere or edit the build.xml to do it for me?
Or is there an automatic way provided by seam to add new libraries?
BR,
Cleber
Do I need to copy them manually somewhere or edit the build.xml to do it for me?
If you project was generated by seam-gen simply add library to lib subfolder.
Or is there an automatic way provided by seam to add new libraries?
You can use maven to manage dependencies. Seam projects aren't mavenized by default, but there are community templates of seam maven projects. Fortunately maven will officially supported in Seam 3.
I did find a way to get it done, the 'ear' task in build.xml has a
<includesfile name="deployed-jars-ear.list"/>
If I edit this file (found next to build.xml) and add the names of my libraries to the end of it, they get copied to the lib folder inside my EAR file which is what I need, since I want then to be loaded by the EAR classloader.
It is worth noting for people new to JBoss like me that JBoss ships with a few libraries already deployed under jboss-5.1.0.GA\lib\endorsed that might conflict with yours if you don't watch out.
I recommend using JBoss Tools Eclipse plugin to develop, build and launch Seam applications. I tried both JBoss Tools approach and Seamgen/Ant approach and found myself more productive using the former (much fewer headaches). There are quite a few tutorials explaining how to use Seam with JBoss Tools (e.g. a dedicated chapter in official documentation ).
To the point: while using JBoss Tools all I have to do to add a library to a project is to copy it to WebContent/WEB-INF/lib directory :).

How to get Netbeans 6.5 shareable libraries working

I created a Web application in Netbeans 6.5. Now I want to use the Joda Time library. I want to share this library via subversion, because I don't want my team mates to be dependend on some Netbeans configuration.
Just to get the project working, I first added the library to the Netbeans library (Tools->Library). This worked OK. The JAR is added to the classpath, and is also deployed.
But when I create a shared library (via Project Properties->Libraries->Browse/New Libraries Folder), the JAR is not in the classpath. I get the error message package org.joda.time does not exist on the code import org.joda.time.*.
Any ideas?
What is the scope of this library? Is this library used for just this particular web-application?
If so, can we put the library in the WEB-INF/lib directory and check that into subversion as well?
Libraries in the WEB-INF/lib directory should be automatically added to the classpath of the project.
Here is what I did:
Tools -> Library -> New Library...
called the library joda-time
add added the joda-time-1.6.jar file to it
Project -> Properties -> Libraries
under the compile tab
Add library...
selected joda-time
(Edit, think I see the issue now - but perhaps not).
You need to add the library to the compile libraries AND add it to the distribution libraries. Or am I misunderstanding the question?
when creating a 'new project', there is an option to enable 'dedicated folder for libraries'. That way, the libraries will also be committed to the repository and your peer developer can checkout your project with all the libraries, your project has dependencies upon, thereby eliminating netbeans configuration bound.
In scenario where a project depends on JARs which can be placed in different locations for different users, a named IDE variable can be used.
http://wiki.netbeans.org/NewAndNoteWorthyNB65#section-NewAndNoteWorthyNB65-VariableBasedPathsInJ2SEJ2EEProjects
Another option would be to use the Maven plugin which already works quite well in NetBeans 6.5. A Intranet repository for the Artifact Jar files could be placed on a file server, or managed through a Maven Proxy like Nexus.
This blog entry describes a hack that worked in NetBeans 5. I don't know if it will work in NetBeans 6.5. I also don't know if this will work if you are building files nightly on a server.
http://blogs.oracle.com/gjmurphy/entry/using_netbeans_free-form_projects_as
I remember setting up shared libraries like this 8 years ago in JBuilder. I wish Netbeans had it by now.

Categories