0

I am very new to java and only start to use Eclipse to run some real-time java program. I could not find javax.realtime to import, I get the error:

The import javax.realtime cannot be resolved

Any idea how to resolve this? Do I need to download any extra package or change some project setup?

Alex K
  • 22,315
  • 19
  • 108
  • 236
shennyL
  • 2,764
  • 11
  • 41
  • 65

4 Answers4

1

Well, the use of Java language in real-time systems (RTS) isn't widespread for a number of significant reasons. These include the non-deterministic performance effects inherent in the Java language's design, with dynamic class loading, and in the Java Runtime Environment (JRE) itself, with the garbage collector and native code compilation. So, the Real-time Specification for Java (RTSJ) is an open specification that potentiates the Java language to open a more widely door and use the language to build real-time systems.

Real-time (RT) is a broad term used to describe applications that have real-world timing requirements. For example, a non-responsive user interface, which doesn't satisfy an average user's generic RT requirements. This type of application is often described as a soft RT application. The same requirement might be more explicitly phrased as "the application should not take more than 0.1 seconds to respond to a mouse click." If the requirement isn't met, it's a soft failure: the application can continue, and the user, though unhappy, can still use it.

Now, implementing the RTSJ requires support from the operating system, the vitual machine or JRE, and the Java Class Library (JCL).

A real-time operating system (RTOS) is an operating system (OS) intended to serve real-time applications that process data as it comes in, typically without buffer delays.

...

A key characteristic of an RTOS is the level of its consistency concerning the amount of time it takes to accept and complete an application's task; the variability is jitter.

The important thing is that jitter is quantified for the system to be considered real time. From this Wikipedia article, we know that if the jitter is usually bounded, the system is soft real-time. If the jitter is always bounded, the system is hard real-time.

Standard Java applications running on a general-purpose JVM on a general-purpose operating system can only hope to meet soft RT requirements at the level of hundreds of milliseconds. Several fundamental aspects of the language are responsible: thread management, class loading, Just-in-time (JIT) compiler activity, and garbage collection (GC). Some of these issues can be mitigated by application designers, but only with significant work.

You can download a RT implementation from IBM for Java 8 here.

Also you can find more information in this document.

Teocci
  • 7,189
  • 1
  • 50
  • 48
1

Yes, you need a real-time Java library.

There are some intended for embedded systems, a commercial version from Oracle with a trial download, etc.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
1

This package is not a part of built in packages. You will need additional Jar file for this package.

Check this link out.

gprathour
  • 14,813
  • 5
  • 66
  • 90
  • Thanks!! Can you tell me how to include the jar file inside eclipse so I can use it?? Thanks a lot... – shennyL Nov 22 '11 at 06:14
  • to add jar follow this link -> http://stackoverflow.com/questions/719084/how-to-install-javax-and-apache-plugins-in-eclipse – Yagnesh Agola Nov 22 '11 at 06:18
  • I don't have much experience with eclipse. What kind of project are you making on eclipse ? JavaSE or Java EE ? In case of JavaEE you can put the jar file in /WEB-INF/lib and in case of JavaSE there will be some way to put jar file in your class path. – gprathour Nov 22 '11 at 06:20
  • hi, i add in the .jar file, but i still cant some errors like: AsyncEventHandler cannot be resolved to a type it should be inside the javax.realtime... – shennyL Nov 22 '11 at 06:27
  • it sounds like there is no AsyncEventHandler class in javax.realtime package. Either the jar has not been successfully integrated or there is no class with that name. – gprathour Nov 22 '11 at 06:31
  • if you import javax.realtime.*; then does it show any error ? or the package is imported? – gprathour Nov 22 '11 at 06:31
  • But it should be inside.. http://jrate.sourceforge.net/api/stable/javax/realtime/package-summary.html No error shown.. i think the package is imported, but it dint contain the class... – shennyL Nov 22 '11 at 06:38
  • okay ! do one thing try to import javax.realtime.AsyncEventHandler, if this thing gives you error then there is no class with that name in jar you have imported. but if it works fine, then there is some other issue. – gprathour Nov 22 '11 at 06:42
  • okay.. there is no that class in the .jar file.. any idea where can I find a complete package of javax.realtime?? Thanks... – shennyL Nov 22 '11 at 06:47
  • well I don't know any particular site for that till now. Check on net. hopefully you will get one. – gprathour Nov 22 '11 at 06:54
1

Note that, to actually get real-time performance out of any javax.realtime package (which implements the Real Time Specification for Java) you'll almost certainly also require 1) a JVM that's modified to work with that javax.realtime package, and 2) to run on a real-time operating system.

What JVM are you currently using? If it happens to be IBM WebSphere Real Time (which is available for free on developerworks at https://www.ibm.com/developerworks/java/jdk/linux/download.html : look for WebSphere Real Time V3 for RT Linux), then you'll also need to specify -Xrealtime on your java command line to run Java programs that use javax.realtime classes.

Mark
  • 46
  • 2
  • To my knowledge (full disclosure: I work for IBM) jRockit does not have support for the RTSJ, so you will not be able to run javax.realtime code on that JVM. I have never used jRate, so I can't help you access javax.realtime with that JVM. Sorry. – Mark Dec 09 '11 at 17:01