Monday, April 28, 2014
Sunday, April 27, 2014
Get number of memory in Java VM
Every Java application has a single instance of class java.lang.Runtime that allows the application to interface with the environment in which the application is running.
- long freeMemory()
Returns the amount of free memory in the Java Virtual Machine. - long maxMemory()
Returns the maximum amount of memory that the Java virtual machine will attempt to use. - long totalMemory()
Returns the total amount of memory in the Java virtual machine.
public class testMem {
public static void main(String[] args){
System.out.println("helloraspberrypi.blogspot.com");
//the total amount of memory in the Java virtual machine
long totalMem = Runtime.getRuntime().totalMemory();
//the maximum amount of memory that the Java virtual machine will attempt to use
long maxMem = Runtime.getRuntime().maxMemory();
//the amount of free memory in the Java Virtual Machine
long freeMem = Runtime.getRuntime().freeMemory();
System.out.println("totalMemory() - " + totalMem);
System.out.println("maxMemory() - " + maxMem);
System.out.println("freeMemory() - " + freeMem);
}
}
We can run java with -Xms and -Xmx options to set Java heap size:
Run on Raspberry Pi:Friday, April 18, 2014
How can I become a good programmer
"Everybody in this country should learn how to program a computer...
because it teaches you how to think" ~ Steve Jobs
because it teaches you how to think" ~ Steve Jobs
A motivational video for new beginner programmers by industrialist and entertainers like: bill gates, larry wall, mark zuckerberg and will i am.
Thursday, April 17, 2014
Raspberry Pi Takes a Swim!
Raspberry Pi submerged in mineral Oil!
***NOTE: DO NOT USE WATER, ONLY MINERAL OIL!
***NOTE: DO NOT USE WATER, ONLY MINERAL OIL!
Tuesday, April 15, 2014
The MagPi magazine, issue Apr 2014 released
The new The MagPi magazine, issue 22, Apr 2014 released, visit http://www.themagpi.com/issue/issue-22/ to download.
Upload file using Node.js with formidable
This example implement web app using Node.js with formidable. formidable is a node.js module for parsing form data, especially file uploads. By default, the uploaded file will be aved in /tmp directory.
To install formidable, run the command in your working directory:
$ npm install formidable
Example code, app.js (tested on Raspberry Pi and Ubuntu):
index.html
Upload file using Node.js with formidable, tested on Raspberry Pi.
To install formidable, run the command in your working directory:
$ npm install formidable
Example code, app.js (tested on Raspberry Pi and Ubuntu):
// run the command to install formidable
// $ npm install formidable
var formidable = require('formidable');
var http = require('http');
var util = require('util');
var fs = require('fs');
var os = require('os');
var app = http.createServer(
function(req, res){
switch(req.method){
case 'GET':
showPage(req, res);
break;
case 'POST':
upload(req, res);
break;
}
}
);
app.listen(8080);
//Display my IP
var networkInterfaces=os.networkInterfaces();
for (var interface in networkInterfaces) {
networkInterfaces[interface].forEach(
function(details){
if (details.family=='IPv4'
&& details.internal==false) {
console.log(interface, details.address);
}
});
}
function showPage(req, res){
fs.readFile(__dirname + '/index.html',
function (err, data) {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
function upload(req, res){
var form = new formidable.IncomingForm();
form.parse(req, function(err, fields, files) {
res.writeHead(200, {'content-type': 'text/plain'});
res.end('File uploaded!');
console.log("Upload completed");
console.log(util.inspect(files));
});
}
index.html
<html>
<head></head>
<body>
<h1>Upload file</h1>
<h1>Test Node.js with formidable</h1>
<div>
<form action="/upload" enctype="multipart/form-data" method="post">
<input type="file" name="file"><br>
<input type="submit" value="Upload">
</form>
</div>
</body>
</html>
Upload file using Node.js with formidable, tested on Raspberry Pi.
Sunday, April 13, 2014
Install Bluefish Editor on Raspberry Pi
Bluefish Editor is a powerful editor targeted towards programmers and webdevelopers, with many options to write websites, scripts and programming code. Bluefish supports many programming and markup languages. Bluefish is an open source development project, released under the GNU GPL licence.
To install bluefish on Raspberry Pi, run the command:
$ sudo apt-get install bluefish
To install bluefish on Raspberry Pi, run the command:
$ sudo apt-get install bluefish
Tuesday, April 8, 2014
Internet of Things, Java and Raspberry Pi
In this session, we invited Oracle engineer Gary Collins, who is responsible for testing and running Java SE Embedded in many many different types of boards, single board computers, plug computers and other. Vinicius Senger and Gary Collins will be talking about IoT and how all those different types of small computers can help us to implement nice solutions. Gary will be showing about at least 10 different computers and they will be sharing experiences like the JavaOne 2013 chess machine and Vinicius's new project involving sailing boats and IoT!
Internet of Things, Java and Raspberry Pi
Internet of Things, Java and Raspberry Pi
Monday, April 7, 2014
Saturday, April 5, 2014
Wednesday, April 2, 2014
Download Java ME Embedded Getting Started Guide
The Beta Draft of Java ME Embedded Getting Started Guide for Java ME Embedded 8 Early Access Release published.
Support Platforms included:
Related:
- Introduction of Java ME Embedded 8
Support Platforms included:
- Qualcomm IoE: describes how to install and run the Oracle Java ME Embedded software on the Qualcomm IoE reference platform.
- Raspberry Pi: describes how to install and run the Oracle Java ME Embedded software on the Raspberry Pi reference platform.
- Windows (via Java ME SDK): describes how to use Oracle Java ME SDK 8 EA 2 to develop embedded applications, using the NetBeans 8.0 Beta Integrated Development Environment, on a Windows 7 platform.
Available at Oracle Java ME for Embedded Devices Documentation.
Related:
- Introduction of Java ME Embedded 8
Introduction of Java ME Embedded 8
This video introduce how to become an Embedded Developer using Java ME Embedded 8.
Jump into the new wave of machine-to-machine technology and the Internet of Things (IoT) with Java ME Embedded 8. The session will provide the know-how to become an embedded Java developer in minutes.
- Introduce background and overview of Java Micro Edition (ME) 8
- Getting started with Hardware (Raspberry Pi), Software (APIs) and Tools (Netbeans) to develop application for Raspberry Pi.
- Examples of using GPIO and I2C.
- Conclusion
Download Oracle Java ME SDK
Be an Embedded Developer in Minutes Using Java ME Embedded 8
Jump into the new wave of machine-to-machine technology and the Internet of Things (IoT) with Java ME Embedded 8. The session will provide the know-how to become an embedded Java developer in minutes.
Subscribe to:
Posts (Atom)