|
I am afraid that I can't rewrite the code since it is ported from 8051 assembler to C#. I thought we could do something with
if/else to
goto ?
|
|
|
|
|
Since there is no goto statement in Java, you really do not have much choice.
Veni, vidi, abiit domum
|
|
|
|
|
Hello
i'm looking for a tool that can generate the needed JNI code using only header file in order to call native C/C++ functions from a library (.so file). i'm having hard time to find the documentation i need to understand the tools so i try to ask here
i'm using eclipse on linux
the popular tools are - SWIG, JNIWrapper, Gluegen, JNA, Bridj.
i wish the tool could do the following:
1. Generate JNI code that needed to call C/C++ code? (not another wrape like SWIG does)
2. Generate conversion code in the JNIEXPORT-JNICALL methods so a structs inside structs will also will be converted automatically and not only the external struct. SWIG, for example is passing a pointer only to the external struct.
3. Good performance. Does anywone ever checked those tools?
4. Examples. if you have examples i'd love to receive.
Thanks a lot in advance
Tomer
|
|
|
|
|
|
Thank you Veni
i don't want to write manually the JNI code. i'm looking for a tool that could do that with given header(.h) file.
Do you know if such tool exist and answers my needs?
Thanks
|
|
|
|
|
The javah command generates the basic .h files, which is about all you can do automatically. I don't know what other code you imagine can be generated for you.
Veni, vidi, abiit domum
|
|
|
|
|
The javah command generates only the signatures of the methods but it doesn't generates conversion of the parameters i want to pass. Until now i managed to work only with 1 out of many tools exist - SWIG: http://en.wikipedia.org/wiki/SWIG[^]
SWIG command generates part of the implementation file (.c file) and converts variables to JNI types. For example it generates code of conversion from int to jint. One disadvantage of SWIG is that it doesn't convert internal struct if this one is inside external struct
|
|
|
|
|
I have data in MySQL database i retrieve them to draw Graphics2D shapes, the data Stored in database as Medium-Text,
each 6 points(coordinates) in single line, i spilt spaces,new line and i parsed String[] to double[], i created 4 classes, -1st class for retrieving data from database.
-2nd class for pathEntry extends JPanel i declared 6 double variables to use them in paintComponent() method in curveTo() method(to draw curves).
-3rd class for Paths extends JPanel where i used ArrayList<pathentry> and called moveTo() method and loop on paintComponent() method in pathEntry class
-4th class i used JFrame to draw all Shapes are called from the last 3 classes to draw Shapes.
i stuck in the shapes did not display on the JFrame ?
1st Class:
public class selectStmt {
public Paths db = null;
.....
String values = null;
int noPrint = 0;
while (rs.next()) {
values = rs.getString(1);
String[] valueNewLine = values.split("\\r\\n");
double[] Points = new double[valueNewLine.length];
for(int i=0;i<valueNewLine.length;i++){
Points = StringtoDoubleArray (valueNewLine [i]);
db.add(valueNewLine[i]);
db.MoveToX= Points [Points.length - 2];
db.MoveToY = Points [Points.length - 1];
noPrint++;
if(noPrint % 6 == 0) {
System.out.println();
noPrint = 0;
}}
...
public double[] StringtoDoubleArray (String str){
double[] result = new double[6];
String[] temp = str.split("\\s");
for(int i=0;i<temp.length;i++){
result [i] = Double.parseDouble(temp[i]);
}
return result;
}
2nd Class:
public class Paths extends JPanel{
public double MoveToX=0;
public double MoveToY=0;
ArrayList <pathEntry> p=new ArrayList<pathEntry>();
<a href="/Members/override">@Override</a>
public void paintComponent(Graphics g) {
super.paintComponent(g);
update(g);
}
public void update(Graphics g){
Graphics2D g2d = (Graphics2D) g;
GeneralPath path=new GeneralPath();
path.moveTo(MoveToX,MoveToY);
for ( int i = 0 ; i < p.size() ; i++ ) {
p.get(i).paintComponent(g2d);
}
}
public void paint_dump() {
System.out.println(MoveToX+" "+MoveToY);
for ( int i = 0 ; i < p.size() ; i++ ) {
System.out.println(p.get(i));
}
}
public void add (String pathstr) {
pathEntry pe=new pathEntry();
String[] temp = pathstr.split("\\s");
pe.cx1 = Double.parseDouble(temp[0]);
pe.cy1 = Double.parseDouble(temp[1]);
pe.cx2 = Double.parseDouble(temp[2]);
pe.cy2 = Double.parseDouble(temp[3]);
pe.x2 = Double.parseDouble(temp[4]);
pe.y2 = Double.parseDouble(temp[5]);
this.p.add(pe);
}
}
3rd Class:
public class pathEntry extends JPanel{
public double cx1 = 0;
public double cy1=0;
public double cx2=0;
public double cy2=0;
public double x2=0;
public double y2=0;
<a href="/Members/override">@Override</a>
public void paintComponent(Graphics g) {
super.paintComponent(g);
update(g);
}
public void update(Graphics g){
Graphics2D g2d = (Graphics2D) g;
GeneralPath path=new GeneralPath();
path.curveTo( cx1 , cy1 , cx2 , cy2 , x2 , y2 );
g2d.draw(path);
g2d.fill(path);
}
}
4th Class :
public class Main extends JFrame {
public selectStmt s;
public static void main(String[] args){
Main m=new Main();
}
public Main(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1024, 768);
setTitle("Drawing Shapes");
setVisible(true);
s = new selectStmt();
add(s.db);
s.db.paint_dump();
}
}
modified 31-Dec-13 5:38am.
|
|
|
|
|
In your 3rd class you create a Path without an initial MoveTo .
Veni, vidi, abiit domum
|
|
|
|
|
i solved it with other way in 3nd class
public void paint (Graphics g, GeneralPath path) {
path.curveTo( cx1 , cy1 , cx2 , cy2 , x2 , y2 )};
and in the 2rd class i replaced with g2d.draw(path); instead in of 3rd class
Thanks anyways
|
|
|
|
|
is it possible to connect finger print module with web page for accessing attendance(using finger print module). If It is possible,then how?. pls send ans to my email odileepshkumaro@live.com
R.Dileep Kumar
|
|
|
|
|
Member 10487162 wrote: is it possible to connect finger print module with web page
Depends on what you mean exactly - but in general it is pointless to have a "web page" with a "remote" device. So of course that means the device would need to be on the box running the browser. In that situation interfacing with the device, at some level, is going to require JNI, so it means messing around a bit with the security of the browser. But of course such a setup is already a internal application anyways so that shouldn't be a problem.
Member 10487162 wrote: pls send ans to my email odileepshkumaro@live.com
No.
|
|
|
|
|
Hi,
I wanted to build unified client application which could able to understand multiple web services (Service provider) for the various category
All the request from our client(jsp/html) should be a web services and should talk with Mangomelon server, which in turn talk with third party server
I want to create servlet program to access multiple web-services
please let us solve this problem
|
|
|
|
|
Requirements are far from complete but the basic process is.
1. Learn how to call an external Web API in java
2. Code it to call one service
3. Wrap that in a class.
4. Depending on the exact APIs that you are calling you might be able to use the same class or copy and modify for each different external Web API
5. Use the above in your servlet.
I suggest STRONGLY that you consider error scenarios where the external servers fail to connect, or fail to respond. If you just assume they will work all of the time then when they do fail you will have no idea what is going on.
|
|
|
|
|
I wrote a test operation like this:
@WebMethod(operationName="setSomeInfo")
public String setSomeInfo(List<String> values){
String retval = "";
List<String> x = values;
if(x.size() > 3){
retval = x.get(3);
}
return retval;
}
and this works perfectly.
However, When I create an object like this:
public class MyWSObject {
private String mystring;
private List<String> mystringarr;
public void setMyString(String value){
mystring = value;
}
public void setMyStringArr(List<String> values){
mystringarr = values;
}
public String getMyString(){
return mystring;
}
public List<String> getMyStringArr(){
return mystringarr;
}
}
and I use it in an webmethod:
@WebMethod(operationName="setSomeInfo")
public String setSomeotherInfo(MyWSObject myobject){
String str_val = myobject.getMyString();
List<String> str_list = myobject.getMyStringArr();
}
I cannot consume it (completely). In the client the MyWSObject is recognized with the methods setMyString , getMyString and getMyStringArr , but not setMyStringArr .
I looked this up and it seems to be a known problem, but I find it hard to believe that something basic as an array or a list is so hard to define. I'm working with NetBeans/glassfish.
Is there a simple solution to this?
(Most solutions I found involved modifying the wsdl, setting compilation options or writing wrapping classes or a combination of those.)
|
|
|
|
|
You did try it with an array rather than the List?
|
|
|
|
|
|
Hi...I am now a days learning Java Language and for which I want some good basic tutorials.Any one who are having can provide me. Thanks in advance.
|
|
|
|
|
|
|
You should tell the original poster, not me.
Veni, vidi, abiit domum
|
|
|
|
|
How can I simulate turing machine in java?
I have simulate DFA and NFA for my task..
|
|
|
|
|
Hello! How do U do?
Can you advice me on how to send a text message from my java application to mobile phones(many cell phones at a time)?
Thanks!
|
|
|
|
|
|
without getway we cant send sms to any mobile number
|
|
|
|