using java to read data from serial port in Tiny OS - java

I am going through Tiny OS tutorial lesson number 4 "Mote-PC serial communication and SerialForwarder" and I am stuck on the line where it says
"Once you have installed TestSerial, you need to run the corresponding Java application that communicates with it over the serial port. This is built when you build the TinyOS application. From in the application directory, type
$ java TestSerial
However when I type this, I face the following error
Error: Could not find or load main class TestSerial
I tried several things to fix this issue, but none helped.
Solutions that I tried:
set CLASSPATH to the directory that I am currently in, which is
export CLASSPATH=.:/home/wsn/tinyos-main/apps/tests/TestSerial
2)set CLASSPATH to the directory where tinyos.jar is located
export CLASSPATH=.:/home/wsn/tinyos-main/support/sdk/java/tinyos.jar
3)run command using java -cp . TestSerial
however I keep having the same error
Is there any other better way to fix it?
I am using Virtual Machine with Fedora OS
I am trying to run the program on mib520 platform and I use iris motes
my java version
openjdk version "1.8.0_31"
OpenJDK Runtime Environment (build 1.8.0_31-b13)
OpenJDK Server VM (build 25.31-b07, mixed mode)

You must have skipped the step when you had to run the make command.
Navigate to the apps/tests/TestSerial folder and type make [platform] (such as make telosb, make iris e.t.c), the makefile that will be run will be the makefile in the TestSerial folder which is defined as follows:
COMPONENT=TestSerialAppC
TOSMAKE_PRE_EXE_DEPS += TestSerial.class
TOSMAKE_CLEAN_EXTRA = *.class TestSerialMsg.java
TestSerial.class: $(wildcard *.java) TestSerialMsg.java
javac -target 1.4 -source 1.4 *.java
TestSerialMsg.java:
nescc-mig java $(CFLAGS) -java-classname=TestSerialMsg TestSerial.h test_serial_msg -o $#
TINYOS_ROOT_DIR?=../../..
include $(TINYOS_ROOT_DIR)/Makefile.include
So the makefile compiles TestSerial.java. After this you can proceed to installing the application and then running the TestSerial application.
So step by step on a iris mote for example you would
Navigate to the apps/tests/TestSerial Folder
Make the application by typing make iris
Connect your mote and then type motelist. This command will list all connected motes. The name of your mote should be listed under the "Device" section. Note this for use in the next two steps.
Install your application by typing the command make iris install.1 bsl, [DEVICE NAME]. This will make and upload your program to your device.
Run the TestSerial application by running java TestSerial -comm serial#[DEVICE NAME]:iris
If you use another platform such as telosb then just replace all occurances of iris in the commands above with telosb.

Related

Unable to get GaalVM to work on latest version of OS/X?

I have tried loading the latest versions of GraalVm from the site onto OS/X from : graalvm-ce-java11-darwin-amd64-20.2.0.tar.gz
I tar this bundle, following the instructions and sudo mv the directory to /Libaray/Java/JavaVirtualMachines and setup the .bash_profile per the instructions. If I run the java_home -V command I see the VM there.
When I try to execute any of the command line utilizes from the VM (java, javac, jar, etc.) I get a fault by OS/X saying the application is from an untrusted developer. I then I have to to control panel/security and settings/general and manually select each an every binary and each and every native library one at a time and tell OS/X to add them as an exception to allow them to be run.
Am I missing something or is this expected behavior? Is there a better way to install the graalVM on OS/X?
This is an old issue but maybe it helps:
https://github.com/oracle/graal/issues/1724
I wonder why this has not been fixed yet.

Running two versions of java on the same linux server via same user for different application

I have two versions of java running on my local server. I wish to use one java version for 1 application and another java version for another application. The user is same. I have been trying to explore different options and I am stuck now. Can somebody please guide me how to go about it
alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
*+ 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
2 /usr/java/jdk1.8.0_101/bin/java
The default version is 1.7 but I wish to run a script which displays the java version as 1.8. Basically, I wish to use java 1.8 only for that bash script without changing the default version of java running on the machine.
I have created a bash script with the export path of the java 1.8
export JAVA_HOME=/usr/java/jdk1.8.0_101/bin/java
export PATH=$PATH:/usr/java/jdk1.8.0_101/bin
JAVA_VERSION=java -version 2>&1 |awk 'NR==1{ gsub(/"/,""); print $3 }'
export JAVA_VERSION
echo $JAVA_VERSION
The output of this bash script still displays the java version as 1.7. Am I doing something wrong?
You reference the full path when kicking off the JVM. I don't really know the context, but this could be via a cron job or shell script or configured in your app server.
For example:
/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java Main
/usr/java/jdk1.8.0_101/bin/java Main2

JInput on RaspberryPi

I am trying to get JInput working on a raspeberryPi. I know it is not ideal to use JInput without an ide, but the Raspberry Pi is too slow to work with most of them. I have managed to sucessfully compile and run my program from the command line on windows. However, on the pi i am having trouble. The pi is running raspbian, java version 1.7.0_40 with hotspot client vm build 24.0-b56. I have set up the file structure as so:
lib/dist
-jinput-test.jar
-jinput.jar
-Controller
--.dll, .so files
--LinuxEnvironmentPlugin.java
bin
src
I am using the command
java -Djava.library.path=lib/dist/Controller -Djinput.plugins=net.java.games.input.LinuxEnvironmentPlugin -cp bin:lib/dist/jinput.jar:lib/dist/Controller Main
to try and run.
However, i get
"INFO: Failed to load library:" /libjinput-linux64.so: /libjinput-linux64.so: wrong ELF class: ELFCLASSS64"
This is where I am confused. Why is it trying to use the 64 bit file. The rasperry Pi has a ARM version 6 processor, which only works with 32 bit. So why is it looking for the 64 bit file in the first place? I have also tried running with the -d32 option but that doesn't help.
You need a native shared library (JNI) built for the Pi (ARM). Fortunately, there are pre-built raspbian packages for JInput that include the required native library:
sudo apt-get install libjinput-java libjinput-java-doc libjinput-jni
You should also add uinput to the end of /etc/modules so the controller gets detected. If you want a nice GUI to test the controller try also installing:
sudo apt-get install jstest-gtk
you can instal Jinput by
sudo apt-get install libjinput-java libjinput-java-doc libjinput-jni
then find these file on your raspberry pi after installation
jinput-20100502.jar
jinput.jar
jinput-test.jar
libjinput-linux.so
libjinput.so
make a new directory called (let's say) lib in your working directory (a you can name it as you wish)
copy all the files above to the directory lib you just made.
then compile the java file by this way :
sudo javac -cp "/usr/share/java/jinput.jar" Example.java
then run it by this way :
sudo java -Djava.library.path=./lib -cp ./lib/*:. Example
if you make the Example.java from netbeans, remove the package info line at the top. it should work.
• Implemented a workaround.
• Wanted to implement joystick jogging on my Raspberry Pi, Processing3 GUI on a Grbl CNC machine, but hit the JInput <==> ARM incompatibility. Believe Quark is right in asserting that no ARM compatible JInput exists. This is in contradiction to the StackOverFlow thread JInput on RaspberryPi . Tried Albert’s extended apt-get: but no-joy Tried 2021-05-07-raspios-buster-arm64 from https://qengineering.eu/install-raspberry-64-os.html, but processing would not start. Went back to 32bit raspbian.
• Workaround was to add a second Arduino Uno with a USB host shield and run the Logetech 3D Pro joystick off the shield. Modified the Arduino USB Host Shield Library 2.0 le3dp sketch to have all output include an identifying preamble (J0Y) which allows the processing serialEvent to identify which USB port belongs to the Grbl Arduino and which is the joystick Arduino. Working code is at https://github.com/TPMoyer/Grbl4P and https://github.com/TPMoyer/LE3DP_4_Grbl4P
this puts the jar files in /usr/share/java/ which needs to be added to the CLASSPATH. I am still looking for the .so files which need to be added to the LD_LIBRARY_PATH

Unable to run threaded java jar file on Mac OS X 10.6.8 with Java 1.7.0.45 using pacifist

I have installed Java 1.7.0_45 on Mac OS X 10.6.8 using Pacifist [http://www.charlessoft.com/] however I am unable to run a jar file which I have downloaded. The jar file is a threaded application.
The error message I am getting is:
java -jar context.jar
2013-10-31 14:14:41.898 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement methodSignatureForSelector: -- trouble ahead
2013-10-31 14:14:41.900 java[330:a07] *** NSInvocation: warning: object 0x109356390 of class 'ThreadUtilities' does not implement doesNotRecognizeSelector: -- abort
Trace/BPT trap
Is there anyway I can run the jar. I have set the JAVA_HOME path properly and java -version is showing 1.7.0_45 as the version.
The same application works properly on Windows Java 1.7.0_45 and also on Linux Java 1.7.
The web search for the solution and the given keywords return very few results and none of them have any specific solution in it. I am new to mac so I am not fully able to understand the issue.
Alternatively, is there anyway I can run Java from folder in Mac like I can do in windows and Linux by just extracting the Java contents and changing the JAVA_HOME. If that is possible then I should be able to run my JAR.
I had kind of same problem while installing an application through jar file, my Java was not detected by the jar application installer,
Over here I see that one of the method is not accessible, could be a same problem. But I am not very sure of it.
make sure you have rt.jar in your JAVA_HOME/jre/lib/ folder
In case you don't have then you are required to have it through the process of creation of symbolic link.
In the command below replace your_java_version with proper version matching your requirement.
sudo mkdir -p /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib
Go into the directory:
cd /System/Library/Frameworks/JavaVM.framework/Versions/<your_java_version>/Home/jre/lib/
Create symbolic link :
sudo ln -s ../../../Classes/classes.jar rt.jar
Hope this solves your problem.
I get the exact same problem with MacOS 10.6.8 and JDK 7. In order to run the jar I had to use the System JRE which is 1.6.x (In my case I wanted to install Squirrel
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -jar >squirrel-sql-3.6-MACOSX-install.jar

How to install java 7 on mac in custom location?

I want to install java 7 on mac silently. I am unable to find any documentation/links on the same. Also I don't want it in /Library. Is it possible to install the same on any custom location. I am very new to mac any help is highly appreciated.
Just to make the steps from #HawkMage more explicit (and illustrate them working with JDK8):
Download the binary (eg, jdk-8u5-macosx-x64.dmg) from Oracle
Double click from Finder to mount the Volume. Ignore the window with the “JDK 8 Update x.pkg”
Use pkgutil to expand the contents of the package into a temporary directory:
$ pkgutil --expand /Volumes/JDK\ 8\ Update\ 05/JDK\ 8\ Update\ 05.pkg /tmp/jdkpkg
Then, change to that dir and use cpio to expand the Payload file:
$ cd /tmp/jdkpkg
$ cpio -i < ./jdk18005.pkg/Payload
Finally, move the Home dir to wherever you’d like your JAVA_HOME to live
$ mv Contents/Home /mytools/jdk-1.8.0_05
Unfortunately the "standard" Java that comes on OS X is packaged in a very non-standard way.
It is not as easy as linux, the DMG downloaded gives you a PKG file that if you run it just installs Java. This is not useful if you are trying to keep the standard Java that comes with OS X intact.
What I do is download the DMG file from Oracle and open it but instead of running the PKG I use pkgutil to extract the contents of the package. You will find a directory named jdk*.pkg and in it you will see a file named Payload. This is a GZipped CPIO file and you can extract it by cating it and piping it into cpio -zi. From this you will now have a directory named Contents and under it you will find a directory named Home. This "Home" directory is the what you would normially get with the Linux tar.gz Java download. You can copy it to wherever you want and put the bin directory in your path and set the JAVA_HOME to it and you are good to go.
Just like in Linux, you can pretty much install Java anywhere you like on a mac. You just need to make sure that you add the Java executable to the path or create a symbolic link of the java executable and put it in the /usr/bin/ directory so it can be executed anywhere.
To add Java to path:
1) Modify .bash_profile found in your home director.
2) Add this line: export PATH=/yourjavadir/bin:$PATH
3) Save and exit
4) Then do source .bash_profile to reload the file. You'll only need to do this one time.
To create a symbolic link:
ln -s /yourjavadir/java /usr/bin/java
I had the same issue and just managed to figure it out.
Download and unzip the Java binary in your custom directory. For eg -
/Users/myuser/Documents/jre1.8.0_25.jre
Update your .bash_profile with the following parameters
export JAVA_HOME=/Users/a514624/Documents/jre1.8.0_25.jre/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
Close the terminal window and open it again. Alternately, you could type the command 'source .bash_profile'.
After these steps, if you type java -version on the command prompt, you would see it reflecting the version which you were hoping to see -
$ java -version
java version "1.8.0_25" Java(TM) SE Runtime
Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM
(build 25.25-b02, mixed mode)
Unlink the existing Java softlink (would require root/elevated privileges)
root$ unlink /usr/bin/java
Create a symbolic link to the new Java installation
root$ ln -s /Users/myuser/Documents/jre1.8.0_25.jre/Contents/Home/bin/java /usr/bin/java
Thats it. Life is beautiful after this. Hope this helps!
If you just need JRE/Java Runtime Edition then previous answers arecorrect but if you need JRE and JDK (Java Development Kit) then simply go to below link and select the mac and run the dmg and it's much better and by far the easiest.
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Categories