|
You are right jschell, i posted it at oracle forums too, the thing is no one was actually helping at the J-Interop forum, so i have been posting at some other good forums for help etc...
My only aim is to read a string from a cpp function, doesn't matter if i am using a wrapper. At least if someone could help me how to do this using Native or Standard Java without a wrapper like an example or something. Maybe i can proceed from there.
|
|
|
|
|
Having a C++ written class, you need to convert it into a shared library (so or DLL); for example, suppose you can embed the snippet you are using in C++ (the one you posted before) into a function like LPSTR yourSnippet(). You can dynamically link the generated shared library from Java using: static {System.loadLibrary("libreria.dll");} and declaring method as native : native String getCadena();
When building wrapper header file (with javah) you'll see in .h file type corresponging :
JNIEXPORT jstring JNICALL <<java_function_name>>_getCadena (JNIEnv *, jobject)
You just have to write a C file including the generated header file you builded with javah, and implement <<java_function_name>>get_Cadena function with: return yourSnippet(); . Just compile and link them as shared library 'libreria.dll' and you got it!
I hope helped you.
Best Regards.
|
|
|
|
|
Skynet_Code wrote: Having a C++ written class, you need to convert it into a shared library (so or DLL);
Jinterop is a Java library that by its very nature provides direct access to existing shared libraries. It does that by using dynamic access (via OS calls) in it own jni library.
Thus one does NOT need to create another shared library when using that API.
Jnative is another example of the same sort of thing.
|
|
|
|
|
amarasat wrote: the thing is no one was actually helping at the J-Interop forum
Googling using the following terms seems to provide topics
jinterop bstr
|
|
|
|
|
hello all.
please guide for me connect postgreSQL with netbean(webservice, glassfish).
thanks very much.
phan
nothing
|
|
|
|
|
Google "postgresql glassfish". There are a number of articles that tell you how to do it.
|
|
|
|
|
Hi,
I have a web application which has a simple java class.
In my java class I have a function that returns Collection<classt>.
For example:
Collection<classt> coll = funcA();
I want to somehow print the contents of the coll collection to the screen - this is for debugging purposes.
How can I do this?
I tried throwing an exception - RuntimeException - but it only accepts a string.
I tried converting the collection to a string, but it doesn't work:
Collection <classt> col = funcA();
String str1 = "";
Object[] arrCol = col.toArray();
for (int i = 0; i < col.size(); i++)
{
str1 = str1 + arrCol[i]+ " ";
}
Is there another way I can view during runtime the contents of the collection?
By the way, I am very new to java - i am a C++ programmer...
Thanks!
|
|
|
|
|
Did you try the toString method ?
|
|
|
|
|
toString on what? on arrCol[i]?
arrCol[i].toString() gives me a cannot find symbol error.
|
|
|
|
|
|
Do you mean:
Collection col = funcA();
String sCol = col.toString();
If so it doesn't work...
If it's not what you meant, I would appreciate it if you could write some code since I am very new to Java...
|
|
|
|
|
SWDevil wrote: If so it doesn't work...
What do you mean by it doesn't work ?
|
|
|
|
|
I mean that it does not print out the contents of the array.
it prints out a number of the class or something like that: 116c99d.
|
|
|
|
|
You have to override the toString method for your own objects, so that they can be printed out.
|
|
|
|
|
It's a bit difficult to answer this without knowing what type of Collection you have. Collection is just an interface that can be implemented by any class which can act as a collection of other objects.
If it is a List then you can iterate over the contents of the list and print each in turn (using the enhanced for loop syntax is easiest).
The same is true for a Set.
If it is a Map then the contents of the collection will have two parts: a key and a value, so how you print it will depend on what you want to see (keys, values, or both).
There are other more obscure types of Collection like BeanContextServices or JobStateReasons and I have no idea what they contain so you would need to read the documentation on those.
Some implementations of Collection have an overridden toString() method that lets you see the contents, but not all do.
The simplest thing to do is to call iterator() on the collection and then just loop over that and print whatever it contains. That may be more or less useful depending on what type of collection you have and what is inside it.
|
|
|
|
|
if i am reading right you just need out.print
|
|
|
|
|
Collection c= funcA();
ArrayList al = new ArrayList(c);
Sttring a[] = (String[])al.toArray(new String[al.size]);
System.out.println("The values in Colections are :");
for (int i=0;i
|
|
|
|
|
hi, my name is Amit and I'm a software engineering student in Ben Gurion university in Israel.
I've recently started working on my final project which is a simulator application for multi-agent path-finding algorithms.
the main idea of my project is to be able to test a few pathfinding algorithms (A* for example) on two different environments.
the first is a grid map which is quite simple to implement. the second which is the reason i'm here is map, or more precisely a road map.
each agent in the search algorithm will be represented by a car on the road map where the point is to see the movement of the cars from their starting position to their destination without any collisions between the cars.
so what i need is a way to integrate a road map inside my Java Swing application and be able to draw stuff on the map and get the coordinates for the roads in the map as an input to my search algorithm.
i thought about using google maps for this, as i am a huge fan of google and i thought that the API will be simple and easy to use.
before i jump into studying the google maps API i wanted to make sure that its what i'm looking for and what i wanna do can be done using google maps.
i don't want to start with google maps API and in the middle of the project find out that its not right for the task and have to throw everything. i also thought about using Google earth, but i think 2d maps will be easier to handle and should be good enough for what i wanna accomplish.
so are the things i mentioned possible/not to hard to accomplish using Google Maps API or should i search for alternative?
thanks
Amit Ofer
|
|
|
|
|
Hello.
I think Google Maps API is a very good idea in order you get road map and positioning methods just implemented. Only handicap is that Google Maps is HTTP oriented, and you are thinking of a Swing application (via Applet or Standalone), so you have to decide how to integrate it :
- Case Applet, you can directly communicate with a Javascript controller that exploits Google Maps Api
- Case StandAlone, you could use URL class to wrapper Google Maps Api controller module.
It's more a design decission question than capabilities: if you are not sure about Gogle Maps, try to design your module interfaces covering generic functionalities and having in mind a GOF pattern; if so, your Google Factory implementation will be only a wrapper (one line of code) and if, once started, you detect Google is not reliable for any reason, you don't have to destroy any code, just implement the other factory.
I hope I've helped you.
Best Regards.
|
|
|
|
|
The problem with Google Maps is that i'm not sure that it provides me with the roads data.
i think it only allows to add a viewable map to my application.
what i need is to be able to get the data so i can provide it to my algorithm as input.
I think that what i'm looking for is called a vector map. (so i can represent the roads as a directed graph)
|
|
|
|
|
Hi.
You got that and much more, but embedded in Javascript objects (ideal for working with Ajax);I recommend you to take a look to http://code.google.com/intl/en-UK/apis/maps/documentation/javascript/v2/services.html and you'll see it clearly, your work is in building a wrapper class for "protocol" translation.
It could be helpful for you getting a (free) Google Maps API key and take a look before starting the project to see if it covers what you need.
Best regards
|
|
|
|
|
i want to write a a program that will accept student name and grades and output it.use an array data structure in the implementation this program and implement the following
write method that will traverses the array and allow the user to perform the following processes
a) search for a particular student and his or her marks
b)find the average of all the student in the class
c)find all student with a mark below 50 and output them.
i started off with this codes
import java.util.Scanner;
//import java.lang.String;
public class Main {
public static int n;
//public static String names;
//private static String[] nameS;
//private static String[] nameS;
/**
* @param args the command line arguments
*/
public static void main(String[] args/*,String[] nameS*/) {
Scanner in=new Scanner(System.in);
int Da=0;
int num []=new int[n];
//int x=0;
System.out.printf("%s\n","Enter the Number of student taking This Couse");
n=in.nextInt();
String name[]=new String [n];
System.out.printf("%s %s \n", "index","value");
for (; Da < name.length; Da++ )/*Da 4 Display array*/ {
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
System.out.println("Enter the names of the student");
String names;
names=in.nextLine();
name[n] = new String(names);
for (; Da < name.length; Da++ ){
System.out.printf( "%5d%8d\n", Da, name[Da] );
}
}
}
i can not input the names into the array( name) i created
pls help me
|
|
|
|
|
Please don't repost the same thing again. People have already responded to you below.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Is there any way to check number of profile visits using FaceBook api.......or number or name of persons who visited profile...pls reply...
thnks
|
|
|
|
|
Have YOU checked the API? Look and see. Then if you want some help maybe try here, but I think some Farcebook forum/group would be a better bet as they'll know more about the ins and outs of social engineering.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|