在哪里可以找到并安装org.osgi.framework软件包? [英] Where to find and install org.osgi.framework package?

查看:723
本文介绍了在哪里可以找到并安装org.osgi.framework软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循本教程:

I am trying to follow this tutorial:

apache felix教程#1

但是我不了解目录结构.我在哪里放置Activator.java文件?相对于Activator.java文件,我应该在哪里放置MANIFEST.MF?

But I don't understand the directory structure. Where do I place the Activator.java file? Where, relative to the Activator.java file do I place the MANIFEST.MF?

在本教程中,当我尝试编译Activator.java文件时,出现了org.osgi.framework不存在的错误.在哪里可以得到org.osgi.framework软件包,应该在哪里安装? javac build命令如何知道如何找到org.osgi.framework包?

In this tutorial when I try to compile the Activator.java file, I get errors that org.osgi.framework does not exist. Where can I get the org.osgi.framework package and where should it be installed? How does the javac build command know how to find the org.osgi.framework package?

我正在寻找一个讲解什么是Karaf/Felix框架以及如何使简单示例工作的教程.

I am looking for a tutorial that explains what Karaf/Felix framework is and how to get simple examples to work.

我也尝试按照本教程进行操作: http://kevinboone.net/osgitest.html

I have also tried to follow this tutorial: http://kevinboone.net/osgitest.html

,但它已过时,并且Tick捆绑包步骤的构建失败.具体来说,该命令:

but it is out of date and the building of the Tick bundle step fails. Specifically, the command:

javac -d target/tick/classes -classpath /path/to/karaf/lib/karaf.jar src/net/kevinboone/osgitest/tick/*.java

没有意义,因为在我的karaf安装程序中没有从 karaf下载网站.

Does not make sense because there is not a file "karaf.jar" in my karaf installation that I downloaded from karaf download site.

清单文件中有以下行:

Import-Package: org.osgi.framework

但是在karaf安装中似乎不存在此软件包?

but this package does not seem to exist in the karaf installation?

推荐答案

felix教程已经过时了.

The felix tutorial is horribly outdated.

如果您想学习OSGi,我可以推荐 Apache Karaf演示教程以及路由示例.

If you want to learn OSGi I can recommend the Apache Karaf demo and tutorials as well as the enroute examples.

仍然要回答这个问题.您可以在osgi核心规范jar和felix jar中找到包org.osgi.framework.因此,在编译过程中,其中一个jar必须位于类路径上.

Still to answer the question. You find the package org.osgi.framework in the osgi core spec jar and also in the felix jar. So one of these jars needs to be on the classpath during your compile.

您不应该手工创建清单.而是使用像maven-bundle-plugin这样的插件来创建它.然后,您可以将Activator放置在所需的任何位置,只需要给该工具一个提示即可.

You should not create the manifest by hand. Instead use a plugin like the maven-bundle-plugin to create it. You can then place the Activator where ever you want and simply need to give the tool a hint where it is.

不要在Activator和其他低级OSGi API上花费太多时间.它们不是您应该编写代码的方式.相反,请看一下声明式服务.它允许使用注释来连接您的班级,从而解决了困难的低级任务.

Do not invest too much time into Activator and other low level OSGi APIs. They are not the way you should write code. Instead take a look at declarative services. It allows to wire your classes using annotations an takes care of the difficult low level tasks.

本教程的问题是它们使用了像javac这样的底层命令.如今,您应该始终使用Maven或Gradle之类的构建工具,并在其中声明依赖项.我链接的教程和示例都提供了不错的构建,您也可以将它们用于以后的生产代码.

The issue with the tutorial is that they use really low level commands like javac. Nowadays you should always use a build tool such as Maven or Gradle and declare the dependencies there. The tutorials and examples I linked all provide nice builds that you can also use for your later production code.

这篇关于在哪里可以找到并安装org.osgi.framework软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆