Shall I move from C to Java?

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.

Reply to
dick
Loading thread data ...

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
 Click to see the full signature
Reply to
Tim Wescott

If I design a HW platform, how can I run Java in this bare machine.

Reply to
dick

dick writes: [...]

Your first step should be to find a newsgroup with "java" in its name.

--
Keith Thompson (The_Other_Keith) kst-u@mib.org  
San Diego Supercomputer Center               
 Click to see the full signature
Reply to
Keith Thompson

quoted text - As per my basic understanding, for your hardware platform you need to Develop or Port Java Run Time Environment

-Raxit

Reply to
Sheth Raxit

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
 Click to see the full signature
Reply to
Tim Wescott

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
    formatting link
  2. Use a uC that includes hardware support for Java bytecodes. There are several inexpensive (less than ) 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]
Reply to
Bob

So you can compile programs once in one platform, and run them nowhere?

I bet you can't.

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.

Reply to
Ivar Rosquist

Don't be (a) silly (b) atopical.

You can't in C, either.

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,
 Click to see the full signature
Reply to
Chris Dollin

Why, given you clearly don't know if it's going to do you any good?

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.

Reply to
Hans-Bernhard Bröker

I'll be blunt. If you must ask, you can't.

Reply to
Hans-Bernhard Bröker

Read up on this,

formatting link

"The platform is a combination of the broad-based I/0, a full TCP/IP stack, and an extensible Java runtime environment that simplifies development of the network connected equipment"

and also this

formatting link

and this is not Java, but could be more interesting :

formatting link

a code example is here

formatting link

-jg

Reply to
Jim Granville

Not directly.

My java is *way* rusty but ... you might take a look at the "javah" tool, which is used to generate C/C++ header files and stubs based on a java class file.

--
Michael N. Moran           (h) 770 516 7918
5009 Old Field Ct.         (c) 678 521 5460
 Click to see the full signature
Reply to
Michael N. Moran

[Please don't quote signature blocks. I've correct this here.]

This is, of course, getting way off-topic for comp.lang.c. I'm sure there is an "embedded Java" newsgroup out there, and Google returns a sick amount of hits for that phrase.

However, it may be instructive to consider that implementing embedded systems does not have to be all bare-metal bit-banging. There is a relatively long tradition of interpreted byte-code slinging in the embedded world.

It really depends on your application and deployment.

--
clvrmnky 

Direct replies will be blacklisted.  Replace "spamtrap" with my name to
 Click to see the full signature
Reply to
Clever Monkey

Is there any C syntax extension that support multi-thread like Java syntax? or how can I use C Macro to hide the OS routine call in C program?

I don't like the style: fun(...) { p(); . . . v(); }

I want to use syn fun(...) { . . . }

another question is how to disable "goto", can I write #define goto error("no goto")

Reply to
dick

No.

What makes you think you need to do that, or that OS routine calls would even exist in an embedded systems?

Reply to
Hans-Bernhard Bröker

formatting link

Vladimir Vassilevsky

DSP and Mixed Signal Design Consultant

formatting link

Reply to
Vladimir Vassilevsky

It appears to have nothing to do with C nor with Java.

--
Army1987 (Replace "NOSPAM" with "email")
No-one ever won a game by resigning. -- S. Tartakower
Reply to
Army1987

formatting link
followed by news:comp.lang.java

No.

Do a web search for "JNI java". It's a bloody pain in the posterior. As far as I can see, you have no C questions whatsoever in your post. Probably, Java questions go better in a Java group.

Reply to
user923005

What has Microsoft's proprietary closed nonsense got to do with Java? Or, for that matter, embedded programming?

Reply to
larwe

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.