I would like to add some Java code to my solution. Below is the pure java code. I added the three necessary jar to /applcation_server/lib folder. I have tried adding and not adding the jars to my startup script class path.
I am not sure if you can access external jar files by placing them in lib folder, but as far as i know we can access methods of external JARs by placing them in the application_server/plugins or application_server/beans folder(which will be shipped for smart client directly).
Then we need to access the method by specifying the full hierarchy from package to class to the methods name, e.g:
var webcam = new Packages.com. ... .Webcam.getDefault();
We recently built a webcam bean around the sarxos library which will be going up to servoyforge in the coming weeks.
In the mean time I can either send you the source and or the compiled bean jar file.
Thanks for all your help. Moved the jars to bean folder and with the code below I have a basic webcam capture function. Please forgive me for my ignorance with embedding java in servoy.
var webcam = new Packages.com.github.sarxos.webcam.Webcam.getDefault();
webcam.setViewSize(new Packages.java.awt.Dimension(640,480));
webcam.open();
new Packages.javax.imageio.ImageIO.write(webcam.getImage(),'JPG',new Packages.java.io.File('C:\\webcam1.jpg'));
webcam.close();
What I need the ability to click a button have a webcam preview displayed. Then be able to take a still image and send it to a specific server location.
Hopefully Mccourt.cordingley1372837951’s webcam bean will solve all my problems.
Sorry for the late response. We have been away with cluents all of last week.
The cam bean does have a review functionality and it seaks to non twain devives also.
I will send you tbe bean and source this afternoon.r
Sorry for the late response. We have been away with cluents all of last week.
The cam bean does have a review functionality and it seaks to non twain devives also.
I will send you tbe bean and source this afternoon.r
briese-it:
Hello,
we whould like to test the webcam bean, too. Is it now available for download?
This bean is a project on ServoyForge, but the project leader (in this case McCourt) hasn’t made the project public (yet).
As he said in the previous post in this thread he will be making it available in the coming weeks.
Edit: I now see that his promise to publish is it from last november, so yes…when will it be published ?
McCourt ?
I have ran into another situation where I would like to use external java code. I have attempted to create a plugin for pdfbox with no success . I have switched gears and now I am attempting to access the java directly in servoy. I am using the pdfbox.jar to extract text from PDF’s. I have already placed the pdfbox.jar in the beans folder. Below is what I got so far:
var pdfbox = Packages.org.apache.pdfbox; //code works
pdfbox.ExtractText ???? this is where I run into issues can't get this to work.
The first bit of code calls the jar file from command line through servoy. This works, however I would like to call java or create a plugin for this as in the second example. The code will work in the second code example, but generates an empty text file. #code segment 1
function Pdf()
{
var file = plugins.file.showFileOpenDialog(1,'C:/pdf',false,null,null,'PDF')
if(!file)return;
file = plugins.file.convertToJSFile(file);
if(!file.exists())return;
var name = 'pdf';
var temp = plugins.file.createTempFile('pdf','.bat');
plugins.file.writeTXTFile(temp,'java -jar P:\\servoy\\pdfbox-app-1.8.5.jar ExtractText '+file.getPath());
application.executeProgram(temp);
}
#code segment 2
function Pdf()
{
var file = plugins.file.showFileOpenDialog(1,'C:/pdf',false,null,null,'PDF')
if(!file)return;
file = plugins.file.convertToJSFile(file);
if(!file.exists())return;
Packages.org.apache.pdfbox.ExtractText.main([file.getAbsolutePath(),'C:/pdf/text.txt']);
}
Thanks for all your help. For some reason I can’t get this code to convert the pdf to txt. Sometimes the code creates an empty text file while at other it throws the following error:
Wrapped org.apache.pdfbox.exceptions.WrappedIOException. This is strange because running pdfbox from the command line extracts the same pdfs to text every time.
I am runing Java 1.6
Servoy 5.2.16
pdfbox-app-1.8.5.jar (jar file is placed in application_server\beans)