java ifconfig

V

voger

Is it possible to configure network interfaces in linux using java?
Something like ifconfig or more simple, but writen in java, and without
using any native commands. I don't need to run my code in any other
operating system, just linux, but i need pure java. Can someone point me
in the right direction please?
 
B

Benji

voger said:
Is it possible to configure network interfaces in linux using java?
Something like ifconfig or more simple, but writen in java, and without
using any native commands. I don't need to run my code in any other
operating system, just linux, but i need pure java. Can someone point me
in the right direction please?

Why do you need pure java, if you're doing an OS-specific operation? Why
can't you just write a shell script that does what you want and invoke it
from java?
 
T

Thomas Hawtin

voger said:
Is it possible to configure network interfaces in linux using java?
Something like ifconfig or more simple, but writen in java, and without
using any native commands. I don't need to run my code in any other
operating system, just linux, but i need pure java. Can someone point me
in the right direction please?

Native Linux programs tend to use ifconfig. It's not particularly
reliable way to go about it, but you might as well follow them.

Actually they often use ifup and ifdown. On my machines at least, they
are script files which may do odd things and are version dependent.

Tom Hawtin
 
D

Dennis Willson

Actually ifup and ifdown are used the most. You emulate what they do and they call a bunch of other programs (many written in C) and
scripts to do their job. I see no way to do what they do in "pure" Java. Java does doesn't have the OS API specific interface.

If you're going to be bound to a single OS anyway... just call ifup and ifdown from Java.
 
V

voger

Well, i need pure java because this what my project requires. Just the
kernel, the VM, maybe a boot loader and everything else java. I don't
have to use the command all the time to configure and reconfigure the
network interface. I just need my eth0 configured somehow once the
system is up and running. And that without running any native code.
I don't know, maybe my question is more linux oriented than java
oriented but i thought maybe it is something simple to be done with java.

So another approach... does anyone know any good reference on how linux
configures souch things?
 
B

Benji

voger said:
Well, i need pure java because this what my project requires. Just the
kernel, the VM, maybe a boot loader and everything else java. I don't
have to use the command all the time to configure and reconfigure the
network interface. I just need my eth0 configured somehow once the
system is up and running. And that without running any native code.
I don't know, maybe my question is more linux oriented than java
oriented but i thought maybe it is something simple to be done with java.
So another approach... does anyone know any good reference on how linux
configures souch things?

Yes, this is not a java question - this is a linux question. I would
advise you that you'll need more stuff than you might think. Look at
"small" distros, like tinylinux.
 
O

Oliver Wong

Benji said:
Yes, this is not a java question - this is a linux question. I would
advise you that you'll need more stuff than you might think. Look at
"small" distros, like tinylinux.

If the OP is asking "What API call do I need to make to do this?" then
I'd say it's a Java question.

And the answer I'm giving to the above question is "I wouldn't be
surprised if such a call does not exist." I may be wrong, but configuring
the ethernet adapters on the host machine may be too platform specific for
Sun to have implemented a library for this purpose.

The OP may wish to re-analyse his/her requirements. If it's 100% known
before time that this application will only ever run on Linux, then why not
use something specific to Linux?

- Oliver
 
D

Dennis Willson

This is a little vague. Since I don't think you can actually do it in "PURE" Java then you're project may not be possible. Why does
the project require it if it's OK to be platform specific? The primary reason for doing "PURE" Java is portability.

Is this by chance a school project?



Just the
 
B

Benji

Oliver said:
If the OP is asking "What API call do I need to make to do this?" then
I'd say it's a Java question.

well, we've already established that there is no API call to do that.
And the answer I'm giving to the above question is "I wouldn't be
surprised if such a call does not exist." I may be wrong, but configuring
the ethernet adapters on the host machine may be too platform specific for
Sun to have implemented a library for this purpose.

this was answered by other posters.
The OP may wish to re-analyse his/her requirements. If it's 100% known
before time that this application will only ever run on Linux, then why not
use something specific to Linux?

hence why I said that it is a linux-specific question. (He said that he
wants a distro of linux that *just* runs java, and he wanted java to
do what all of the ifup/down scripts would normally do - which is pretty
much impossible or not useful)
 
B

Benji

Dennis said:
This is a little vague. Since I don't think you can actually do it in "PURE" Java then you're project may not be possible. Why does
the project require it if it's OK to be platform specific? The primary reason for doing "PURE" Java is portability.
Is this by chance a school project?

he already answered all of these questions. read the whole thread. =)
 
D

Dennis Willson

Benji said:
he already answered all of these questions. read the whole thread. =)
No, he didn't answer all those questions and I DID read the WHOLE thread, did you? All he said was:

"Well, i need pure java because this what my project requires. Just the kernel, the VM, maybe a boot loader and everything else java."

How does this answer WHY it's ok to be platform specific but has to be PURE Java? When there is such a specific requirement there's
usually a reason (sometimes good and sometimes bad). Since Java was meant to be non-platform specific, there is no provision to talk
directly to OS APIs. This would rule out "PURE" Java. Was this a school assignment? A job assignment? Or just something he wants to
try and do? If the answer is just "I want to do it that way" or "I can't say" are all perfectly fine answers. The statement "i need
pure java because this what my project requires" does NOT answer WHY.

Dennis
 
B

Benji

Dennis said:
"Well, i need pure java because this what my project requires. Just the kernel, the VM, maybe a boot loader and everything else java."
How does this answer WHY it's ok to be platform specific but has to be PURE Java? When there is such a specific requirement there's
usually a reason (sometimes good and sometimes bad). Since Java was meant to be non-platform specific, there is no provision to talk
directly to OS APIs. This would rule out "PURE" Java. Was this a school assignment? A job assignment? Or just something he wants to
try and do? If the answer is just "I want to do it that way" or "I can't say" are all perfectly fine answers. The statement "i need
pure java because this what my project requires" does NOT answer WHY.

It's platform specific if he's making a distribution that's just enough to
run a kernel and a VM.

The fact that he wants pure java tells me that it's not a school assignment,
as only a boss would know little enough about what he was saying to require
pure java.

we don't really know why in order to tell him that it's a linux question,
since there are no java APIs to deal with stuff like that.
 
A

Andrew Thompson

Dennis Willson wrote:
....
"Well, i need pure java because this what my project requires. Just the
kernel, the VM, maybe a boot loader and everything else java."

How does this answer WHY it's ok to be platform specific but has to be
PURE Java? When there is such a specific requirement there's usually a
reason (sometimes good and sometimes bad).

I agree. I feel that the best answer to this question can
only be arrived at after a closer examination of the *reasons*
for the very specific requirements and constraints.

[ Just my 2c worth. ]
 
R

Roedy Green

I just need my eth0 configured somehow once the
system is up and running. And that without running any native code.

This is a contradiction in terms. Anything platform specific requires
native code. Either you write it or Sun does. Sun has not, so you
will have to.
 
D

David N. Welton

Benji said:
we don't really know why in order to tell him that it's a linux question,
since there are no java APIs to deal with stuff like that.

I have some code available here

http://www.dedasys.com/freesoftware/

that could probably be adapted via JNI to do ifconfig duties for Java.
Look for 'Tcl ifconfig' on the web page. There's also a version
available for Python.

--
David N. Welton
- http://www.dedasys.com/davidw/

Linux, Open Source Consulting
- http://www.dedasys.com/
 
O

Oliver Wong

Benji said:
well, we've already established that there is no API call to do that.

Regardless of whether the answer is "Yes there is" or "No there isn't",
the question itself is still a Java question in my opinion.
this was answered by other posters.

Usenet is not a reliable medium. The post that I wrote and that you're
quoting is dated "2005-11-09 18:16" on my news server, and there are only 3
posts in this thread dated earlier than that; two by voger, and one by you.
So from my perspective, it was not "already established that there is no API
call to do that", and (again, from my perspective), this was NOT answered by
other posters.

Rather than assuming that every question I've seen on usenet may have
been answered already (but just not visible to me) and refraining from
answering ANY questions, I take the opposite approach of answering every
question which I feel qualified to. And if the OP gets two answers to
his/her question, so much the better.

I apologize if my posting philosophy/policy is not compatible with
yours.

- Oliver
 
V

voger

Andrew said:
Dennis Willson wrote:
...
"Well, i need pure java because this what my project requires. Just
the kernel, the VM, maybe a boot loader and everything else java."

How does this answer WHY it's ok to be platform specific but has to be
PURE Java? When there is such a specific requirement there's usually a
reason (sometimes good and sometimes bad).


I agree. I feel that the best answer to this question can
only be arrived at after a closer examination of the *reasons*
for the very specific requirements and constraints.

[ Just my 2c worth. ]


It is a research project. We want to see if it can be done to create
something os like by using pure java. something like jinux
(https://jinux.dev.java.net/). Unfortunately that project seems
abandoned and as i can see from the replies this is not something that
can be done easy.
 
B

Benji

voger said:
It is a research project. We want to see if it can be done to create
something os like by using pure java.

Yeah...that seems like a contradiction in terms. =)
 
O

Oliver Wong

voger said:
It is a research project. We want to see if it can be done to create
something os like by using pure java. something like jinux
(https://jinux.dev.java.net/). Unfortunately that project seems abandoned
and as i can see from the replies this is not something that can be done
easy.

You might want to be very careful how you define "pure Java"

See this thread, and the discussion between Roedy and I, for example:
http://groups.google.ca/group/comp....read/83cce5c1957af0b8/632d4fa48f3e302c?lnk=st

Notice that the jinux project avoids a lot of the difficulties by not
requiring "pure Java", but instead, "100% Java OS above Minimal Linux
Kernel"

- Oliver
 
R

Roedy Green

It is a research project. We want to see if it can be done to create
something os like by using pure java. something like jinux
(https://jinux.dev.java.net/). Unfortunately that project seems
abandoned and as i can see from the replies this is not something that
can be done easy.

There is no way to write platform specific code in pure Java.

That is like asking how do a murder someone without breaking the law.
You can do it your self, but that is breaking the law, or you can
hire someone else to do it for you, but that too is still breaking the
law.

All you are doing metaphorically speaking is looking for a hit man who
will murder on your behalf, but not explicitly tell you that is what
he did.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top