JSimpleModule Step-by-step

First things first

First off, make sure that you have java installed and that you have your JAVA_HOME environment variable set. To check for java, just run java and see what happens. If there’s no program by that name, go install java…

You also want to make sure that your JAVA_HOME environment variable is set, and to make sure that there is no trailing “/” on the value. To check it: echo $JAVA_HOME

Download/Extract JSimpleModule

You can use these commands to download and extract JSimpleModule:

wget http://www.omnetpp.org/filemgmt/visit.php?lid=126
tar xzvf jsimplemodule-3.3-1.tgz

Attempt to build JSimpleModule

Nominally, the following is what you should have to do in order to compile the base JSimpleModule code. However, you will probably run into one of the two problems below. Repeat the last two steps until you can successfully compile these files.


cd jsimplemodule-3.3-1
cp makefrag.SAMPLE makefrag
opp_makemake -f
make

Script Error: Can’t open opp_makedep

if you get an error like this:

/bin/sh: Can't open opp_makedep
Error: command 'opp_makedep -Y --objdirtree -fMakefile -- *.cc' returned nonzero exit code

You’re probably using Ubuntu 6.10+. There’s a mailing list post that describes the problem (ubuntu changed the default shell). The easiest fix is like this:

cd /bin
sudo mv sh sh.orig
sudo ln -s bash sh

Compile Error: …SetBooleanField…

At this point, I started getting compile errors that looked something like this:

JUtil.cc: In member function รข??void JObjectAccess::setBooleanJavaField(const char*, jboolean):
JUtil.cc:153: error: JUtil::jenv->JNIEnv_::SetBooleanField(((JObjectAccess*)this)->JObjectAccess::javaPeer, fieldID, ((int)value)) has type void and is not a throw-expression

I have yet to see any “official response”, but the fix seems to be to turning some of the in-line conditionals into full conditionals. Please see Nuno Alexandre Carvalho’s mailing list post for details on fixing this problem.

Get the example java simulations working

First thing to do is to get this working using the files that are provided. After that, we can start renaming and moving things around to make more sense. For now, just bare with me, ‘k.

The shell script “run” has the wrong line delimiters in it (it was created by a windows/dos machine). To fix this:

dos2unix run

This script calls a program “./yoursimulation”. This doesn’t exist in the directory, so we need to find it. Turns out that all we need is the executable that we compiled in the previous section. Since I don’t like extra copies of stuff hanging around and getting out-of-date, let’s just make a link:

ln -s ../jsimplemodule-3.3-1 yoursimulation

That should be all we need. Let’s try running it:

./run

And viola… the Omnet simulation windows open up (hopefully).

Can’t run: Core dump

This is another problem that Nuno Alexandre Carvalho’s mailing list post addresses. Go back to the jsimplemodule-3.3-1 directory and edit the file Makefile manually. Find the line that looks like this:

CFLAGS=-O2 ...

and make it look like this (by removing the “2” after “-O

CFLAGS=-O ...

Then, from the command line, rebuild:

make clean; make

Can’t run: libjvm.so: cannot open shared object file…

This is an indication that your LD_LIBRARY_PATH environment variable isn’t setup quite right. In my LD_LIBRARY_PATH, I need to include /usr/lib/jvm/java-6-sun-1.6…/jre/lib/i386/client/. You may notice that this is smore eomewhat similar to the PATH variable set up in the run script, so I would actually recommend adding the following line to your run script:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/i386/client

Make it pretty

At this point, you've got something that works, so it's time to make a backup copy! ;-)

Once you've done that, copy the example directory out of the jsimplemodule directory, and update the reference to "../simkernel.jar" in the run script. (I use another soft link in the same directory, but an environment variable or absolute path will work fine too) Then update the link "yoursimulation" to "jsimplemodule-3.3-1" or something similar, and update the last line in the run script to match.

Tags: ,

Leave a Reply