EmbeddedRelated.com
Forums

Shall I move from C to Java?

Started by dick August 14, 2007
Hi everyone,

I am planning to learn Java.

Can I access HW registers in Java? Or can I call C function from Java
program?

Thanks.

On Mon, 13 Aug 2007 22:07:16 -0700, dick wrote:

> Hi everyone, > > I am planning to learn Java. > > Can I access HW registers in Java? Or can I call C function from Java > program? > > Thanks.
Even though I don't know much about Java, I know these tidbits: No, you cannot directly access hardware from Java. I would be surprised to find a serious Java for embedded use that did not include library functions to do so, however. Java itself doesn't provide a means to call C functions, but most Java run time environments provide a means to call external code. Of course, if you're calling external code then you have to maintain code bases in C _and_ Java... -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
Tim Wescott wrote:
> On Mon, 13 Aug 2007 22:07:16 -0700, dick wrote: > > > Hi everyone, > > > > I am planning to learn Java. > > > > Can I access HW registers in Java? Or can I call C function from Java > > program? > > > > Thanks. > > Even though I don't know much about Java, I know these tidbits: > > No, you cannot directly access hardware from Java. I would be surprised > to find a serious Java for embedded use that did not include library > functions to do so, however. > > Java itself doesn't provide a means to call C functions, but most Java run > time environments provide a means to call external code. Of course, if > you're calling external code then you have to maintain code bases in C > _and_ Java... > > -- > Tim Wescott > Control systems and communications consulting > http://www.wescottdesign.com > > Need to learn how to apply control theory in your embedded system? > "Applied Control Theory for Embedded Systems" by Tim Wescott > Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
If I design a HW platform, how can I run Java in this bare machine.
dick <dick_12345678@hotmail.com> writes:
[...]
> If I design a HW platform, how can I run Java in this bare machine.
Your first step should be to find a newsgroup with "java" in its name. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst> "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"
On Aug 14, 9:26 am, dick <dick_12345...@hotmail.com> wrote:
> Tim Wescott wrote: > > On Mon, 13 Aug 2007 22:07:16 -0700, dick wrote: > > > > Hi everyone, > > > > I am planning to learn Java. > > > > Can I access HW registers in Java? Or can I call C function from Java > > > program? > > > > Thanks. > > > Even though I don't know much about Java, I know these tidbits: > > > No, you cannot directly access hardware from Java. I would be surprised > > to find a serious Java for embedded use that did not include library > > functions to do so, however. > > > Java itself doesn't provide a means to call C functions, but most Java run > > time environments provide a means to call external code. Of course, if > > you're calling external code then you have to maintain code bases in C > > _and_ Java... > > > -- > > Tim Wescott > > Control systems and communications consulting > >http://www.wescottdesign.com > > > Need to learn how to apply control theory in your embedded system? > > "Applied Control Theory for Embedded Systems" by Tim Wescott > > Elsevier/Newnes,http://www.wescottdesign.com/actfes/actfes.html > > If I design a HW platform, how can I run Java in this bare machine.- Hide quoted text -
As per my basic understanding, for your hardware platform you need to Develop or Port Java Run Time Environment <JVM , regret i am not java guru and This is not Java-news group, regret if you think replying to OT> -Raxit
> > - Show quoted text -
On Mon, 13 Aug 2007 22:26:54 -0700, dick wrote:

> Tim Wescott wrote: >> On Mon, 13 Aug 2007 22:07:16 -0700, dick wrote: >> >> > Hi everyone, >> > >> > I am planning to learn Java. >> > >> > Can I access HW registers in Java? Or can I call C function from Java >> > program? >> > >> > Thanks. >> >> Even though I don't know much about Java, I know these tidbits: >> >> No, you cannot directly access hardware from Java. I would be surprised >> to find a serious Java for embedded use that did not include library >> functions to do so, however. >> >> Java itself doesn't provide a means to call C functions, but most Java run >> time environments provide a means to call external code. Of course, if >> you're calling external code then you have to maintain code bases in C >> _and_ Java... >> >> -- >> Tim Wescott >> Control systems and communications consulting >> http://www.wescottdesign.com >> >> Need to learn how to apply control theory in your embedded system? >> "Applied Control Theory for Embedded Systems" by Tim Wescott >> Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html > > > > > > > If I design a HW platform, how can I run Java in this bare machine.
You need a Java run-time environment to run Java, at which point the machine would no longer (by my definition) be "bare". -- Tim Wescott Control systems and communications consulting http://www.wescottdesign.com Need to learn how to apply control theory in your embedded system? "Applied Control Theory for Embedded Systems" by Tim Wescott Elsevier/Newnes, http://www.wescottdesign.com/actfes/actfes.html
On Aug 13, 10:26 pm, dick <dick_12345...@hotmail.com> wrote:
> > If I design a HW platform, how can I run Java in this bare machine
A typical embedded system will not have the CPU power or memory to interpret the bytecode at runtime, so that leaves two options: 1. Use a compiler that generates native machine code. See http://gcc.gnu.org/java/ 2. Use a uC that includes hardware support for Java bytecodes. There are several inexpensive (less than $10) microcontrollers based on the ARM926EJ-S core, including Atmel's AT91SAM9260 and NXP's LPC3180. My opinion is that Java is a poor language choice for most embedded system projects. But you can come to you own conclusion about that. [comp.lang.c removed from newsgroups]
On Mon, 13 Aug 2007 22:07:16 -0700, dick wrote:

> Hi everyone, > > I am planning to learn Java.
So you can compile programs once in one platform, and run them nowhere?
> Can I access HW registers in Java?
I bet you can't.
> Or can I call C function from Java program?
Yes - using JNI. The catch is that the overhead introduce by this is such that in most cases the resulting code is almost as slow as an all Java code.
Ivar Rosquist wrote:

> On Mon, 13 Aug 2007 22:07:16 -0700, dick wrote: > >> Hi everyone, >> >> I am planning to learn Java. > > So you can compile programs once in one platform, and run them > nowhere?
Don't be (a) silly (b) atopical.
>> Can I access HW registers in Java? > > I bet you can't.
You can't in C, either.
>> Or can I call C function from Java program? > > Yes - using JNI. The catch is that the overhead introduce by this > is such that in most cases the resulting code is almost as slow as an all > Java code.
That is, of course, going to depend on how much work the C code does; "most cases" is sheer handwaving. -- Chris "(render unto \X that which is X's)(C | Java)" Dollin Hewlett-Packard Limited registered office: Cain Road, Bracknell, registered no: 690597 England Berks RG12 1HN
[X-post lacked a F'up2; reduced to one group]

dick wrote:

> I am planning to learn Java.
Why, given you clearly don't know if it's going to do you any good?
> Can I access HW registers in Java? Or can I call C function from Java > program?
If you must ask, that strongly implies it's a bad idea for you to learn Java at this point. You have to analyze what it means to use Java instead of C first.