Go Down

Topic: JAVA & YUN (Read 6174 times) previous topic - next topic

sonnyyu

Jan 31, 2015, 12:56 am Last Edit: Jan 31, 2015, 05:57 am by sonnyyu Reason: add GNU Classpath URL
Latest version is JamVM 2.0.0, released on 30th July 2014. JamVM is compatible with the class-library from OpenJDK 6, 7 and 8 (the latest).

http://jamvm.sourceforge.net/

http://www.gnu.org/software/classpath/

I backport jamvm and classpath to current version.

First remove old one if it is installed.

Code: [Select]
opkg remove jamvm
opkg remove classpath


Code: [Select]
cd /mnt/sda1
wget -O  classpath_0.99-1_ar71xx.ipk https://www.dropbox.com/s/fgijxd8o8pmn2x1/classpath_0.99-1_ar71xx.ipk?dl=0 --no-check-certificate
wget -O  jamvm_2.0.0-1_ar71xx.ipk https://www.dropbox.com/s/r3vova5k09lmft1/jamvm_2.0.0-1_ar71xx.ipk?dl=0 --no-check-certificate


Code: [Select]
opkg install classpath_0.99-1_ar71xx.ipk
opkg install jamvm_2.0.0-1_ar71xx.ipk


Test jamvm installation.

Code: [Select]
root@Arduino:~# jamvm -version
java version "1.5.0"
JamVM version 2.0.0
...
Execution Engine: direct-threaded interpreter with stack-caching
Compiled with: gcc 4.6.3 20120201 (prerelease)

Boot Library Path: /usr/lib/classpath
Boot Class Path: /usr/share/jamvm/classes.zip:/usr/share/classpath/glibj.zip



sonnyyu

Hello World example :

At Linux box:

Code: [Select]
sonnyyu@debian75386240:~/test$ java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~deb7u1)
OpenJDK Server VM (build 24.75-b04, mixed mode)


Code: [Select]
nano HelloWorld.java

Code: [Select]
class HelloWorld
{
   public static void main(String args[])
   {
      System.out.println("Hello World");
   }
}


compile HelloWorld.class file

Code: [Select]
javac HelloWorld.java

copy HelloWorld.class into Yun

Code: [Select]
root@Arduino:/mnt/sda1# jamvm HelloWorld
Hello World





sonnyyu

Create PDF file of US flag.




http://pdfjet.com/net/examples/example-01.html

compile Example_01.java file into Example_01.class at Linux box ( copy PDFjet.jar into same directory)

Code: [Select]
javac -classpath .:PDFjet.jar  Example_01.java

Test it at same box

Code: [Select]
java -classpath .:PDFjet.jar Example_01

copy Example_01.class file into Yun:

Code: [Select]
jamvm -classpath .:PDFjet.jar Example_01

Example_01.pdf is here

https://www.dropbox.com/s/ilcxfz9i90z3j54/Example_01.pdf?dl=0





jessemonroy650

SonnyYu,
Does the dropbox belong to you?
If no, how do you find?
If yes, do you have more? I see you make example many times.  :)

TIA
Jesse

sonnyyu

#4
Jan 31, 2015, 02:06 am Last Edit: Jan 31, 2015, 02:06 am by sonnyyu
SonnyYu,
Does the dropbox belong to you?
If no, how do you find?
If yes, do you have more? I see you make example many times.  :)

TIA
Jesse
https://www.dropbox.com/en/help/73




jessemonroy650

https://www.dropbox.com/en/help/73


SonnyYu,
Sorry I am not clear. I know dropbox. I hate dropbox. I do not like dropbox.

I ask about the updated packages you always make post about. Can you give details about packages? Did you make (compile) updated packages? Did you make more updated packages? How many other updated packages did you make?

TIA
Jesse

sonnyyu

#6
Jan 31, 2015, 06:07 am Last Edit: Jan 31, 2015, 07:02 am by sonnyyu
I ask about the updated packages you always make post about.

Last few packages are not updated but backported, The source is in trunk.

Can you give details about packages?

Linux user space package host by package holder, I will updated my post put url in.

Did you make (compile) updated packages?

Yes.

Did you make more updated packages?

Not realy, AR71XX hardware platform is old.

How many other updated packages did you make?

Not much.




sonnyyu

#7
Feb 03, 2015, 01:52 am Last Edit: Feb 03, 2015, 01:53 am by sonnyyu
JDBC connect with DB(MYSQL):

http://dev.mysql.com/downloads/connector/j/

At Linux Box:

Code: [Select]
nano JDBCExample.java

Code: [Select]
import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
 
public class JDBCExample {
 
  public static void main(String[] argv) {
 
System.out.println("-------- MySQL JDBC Connection Testing ------------");
 
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your MySQL JDBC Driver?");
e.printStackTrace();
return;
}
 
System.out.println("MySQL JDBC Driver Registered!");
Connection connection = null;
 
try {
connection = DriverManager
.getConnection("jdbc:mysql://192.168.0.64:3306/classicmodels","root", "password");
 
} catch (SQLException e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
}
 
if (connection != null) {
System.out.println("You made it, take control your database now!");
} else {
System.out.println("Failed to make connection!");
}
  }
}



Code: [Select]
javac -classpath .:mysql-connector-java-5.1.34-bin.jar JDBCExample.java

java  -classpath .:mysql-connector-java-5.1.34-bin.jar  JDBCExample



copy mysql-connector-java-5.1.34-bin.jar and JDBCExample.class into Yun.

Code: [Select]
root@Arduino:/mnt/sda1# jamvm  -classpath .:mysql-connector-java-5.1.34-bin.jar
 JDBCExample
-------- MySQL JDBC Connection Testing ------------
MySQL JDBC Driver Registered!
You made it, take control your database now!




sonnyyu

JDBC connect with MSSQL:


Download jtds-1.2.8.jar

http://sourceforge.net/projects/jtds/files/jtds/


At Linux Box:

Code: [Select]
nano DemoJdbcRowSet.java


Code: [Select]
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.rowset.JdbcRowSet;
public class DemoJdbcRowSet {
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  try {
   //import driver
   Class.forName("net.sourceforge.jtds.jdbc.Driver");
   //connection to database
   Connection conn=DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.100:1433;databaseName=test;user=sa;password=password;");
   Statement state=conn.createStatement();
   String sql="SELECT * FROM areacode where id=1";
   ResultSet result=state.executeQuery(sql);
   while (result.next())
   {
    System.out.println(result.getString("id")+"\t"+result.getString("areacode"));
   }
  } catch (ClassNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (SQLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
}



Code: [Select]
javac -classpath  .:jtds-1.2.8.jar  DemoJdbcRowSet.java
java -classpath  .:jtds-1.2.8.jar  DemoJdbcRowSet



copy jtds-1.2.8.jar and DemoJdbcRowSet.class into Yun.

Code: [Select]
root@Arduino:/mnt/sda1# jamvm  -classpath  .:jtds-1.2.8.jar  DemoJdbcRowSet
1       354

e2sence

JDBC connect with MSSQL:


Download jtds-1.2.8.jar

http://sourceforge.net/projects/jtds/files/jtds/


At Linux Box:

Code: [Select]
nano DemoJdbcRowSet.java


Code: [Select]
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.sql.rowset.JdbcRowSet;
public class DemoJdbcRowSet {
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  try {
   //import driver
   Class.forName("net.sourceforge.jtds.jdbc.Driver");
   //connection to database
   Connection conn=DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.100:1433;databaseName=test;user=sa;password=password;");
   Statement state=conn.createStatement();
   String sql="SELECT * FROM areacode where id=1";
   ResultSet result=state.executeQuery(sql);
   while (result.next())
   {
    System.out.println(result.getString("id")+"\t"+result.getString("areacode"));
   }
  } catch (ClassNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (SQLException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
}



Code: [Select]
javac -classpath  .:jtds-1.2.8.jar  DemoJdbcRowSet.java
java -classpath  .:jtds-1.2.8.jar  DemoJdbcRowSet



copy jtds-1.2.8.jar and DemoJdbcRowSet.class into Yun.

Code: [Select]
root@Arduino:/mnt/sda1# jamvm  -classpath  .:jtds-1.2.8.jar  DemoJdbcRowSet
1       354


This also does not work on the current version of Yun ((((((

Go Up