I've found plenty in javascript etc, and for desktop-based ones in Java, but none for web-based java. Any ideas?
For comprehensive access to the Java Sound API, look to the javax.sound.sampled package.
See the Sound Trail of the Java Tutorial for details on how to use the API.
To record sound, the applet would need to be digitally signed (by you) and trusted (by the end user - when prompted at start-up).
Daniel made a good point about sound in web pages. Users generally hate it. Make sure your applet does not attempt to play any sound until requested by the user. Set the volume to a relatively low one.
I believe you can create an applet, which then is embedded into web page. And applets are capable of playing whatever you want, even without authorisation from the user (as far as I remember, it is allowed by JVM sandbox). Applet class even has dedicated method for this: Applet.newAudioClip .
Related
So, how much trust do I need to have in a publisher before I run their applet in the web browser?
In other words, I understand that a java applet is run in a sandbox in the browser, but this article suggests that the applet can actually access files stored on the local computer.
Can you please clarify the security limits of a java applet run in a modern browser, such as Firefox 50?
I understand that a java applet is run in a sandbox in the browser, but this article suggests that the applet can actually access files stored on the local computer.
There are potentially three different levels of security available to a Java applet.
The first is as you described 'sandboxed'. They can only access resources from their own server, nothing on your local file system unless they are launched using Java Web Start & will thereby have access to the services of the JNLP API. You might note that two of the services are the FileOpenService / FileSaveService! If the applet goes to use these, the end user will be prompted to permit the action via a dialog that states what the applet is trying to do, and asking for permission to proceed (to show a file chooser & go from there). These services provide back a 'file like' object that is more limited than the normal File API would supply. For example, it will not provide the path to the resource, just it's name and access to the content.
The level up from that can be specified in the launch file - '(J2EE) application client permissions'. This level removes the prompts for use of the JNLP API services.
The highest level of access is obtained by requesting, and being granted, 'all permissions'. Then the applet should have full access to File objects, be able to communicate with servers other than the one that launched it, etc. One of the few things they would still not be permitted to do in this mode is to call System.exit(n) to effectively 'kill the JRE' - this is something that is commonly done in other desktop apps.
But then there are JRE bugs, that screw all that up. Sun, then Oracle, kept stuffing up security so poorly (& regularly) that many browser manufacturers are entirely removing the support for applets (and other embedded objects requiring plug-ins) in web pages.
See Java Plugin support deprecated and Moving to a Plugin-Free Web for more detail.
..how much trust do I need to have in a publisher before I run their applet in the web browser?
I cannot answer for you, but my take would be that I would need to know them personally, and trust completely both their integrity and competence before I'd run their code in any browser I controlled.
Having said that, I don't think I have a single browser installed that even supports applets, and my complete lack of motivation to set something up, is probably a good view on whether I'd allow applets to run on this PC at all.
My supervisor has tasked me with programmatically reducing a website's content by looking at the HTML tags to reveal only the core content. Importantly, this particular piece of the project must be written in Java.
Now having learnt about the differences betweenPlugins, Extensions, Applets, and Widgets, I think I want to use an Extension that calls a client-side Applet. My approach was going to be this:
Using the Google-Chrome API, I was going to display a button that
the user can click.
If clicked, the action is to launch a new browser tab that has the
Applet embedded within it.
The applet automatically sources the called tab's HTML code and
filters it.
Once filtered, the reduced copy of the original site appears.
So I have a few questions. To start, is it even possible to use an Extension with an Applet? Moreover, is it possible for an applet to look # another tabs HTML code? If not, is it possible to just reload the original tab with the Applet now embedded within it and complete the function. Thanks.
Javascript is already on most mobile web platforms. Java is not, and there is no reasonable way mobile customers will be able to install Java. Android, which runs many, but not all, mobile devices has a Java run time environment, and is basically a loader for Java apps. But an Apple iPhone is not an Android device... nor is a Windows Phone.
If you want to summarize content on the client, and in Javascript, as I see it you have two choices:
Succeed with some inner burst of genius where dozens of the best expert PhDs in Natural Language Computing have just begun exploring how to extract "true meaning" from text; OR
look at document.title and be done with it.
The 2nd approach assumes that the authors of web pages set titles and set a title appropriate for summarizing their website. This isn't a perfect assumption, but it is OK
most of the time. It is also a lot less expensive than #1
With the 1st approach you can get a head start with a "natural language toolkit" that can do things like scan text for unusual words and phrases. To get a rough idea of the kinds of software that have been built in this area, review wikipedia: Outline of natural language processing:: toolkits. A popular tookit for python is called NLTK. Whether you use a toolkit from java, or python, it means working on the server because the client will not have the storage, network speed, or CPU. For python there are server side app frameworks like django or web2py that can make building out a server app faster, and on Java there are servlets frameworks. Ultimately you'll need a lot of help, training, or luck and as I have hinted above it can easily be beyond the capabilities of a small team of fresh hires, and certainly way beyond what a single new developer eager to prove his/her capabilities can do in a few weeks on their own with limited help.
Most web pages have titles set like this near the beginning of the downloaded HTML:
<head><title>My Furry Kittens!</title></head>
You don't need to write a parser. If you are running in the browser, the title has been parsed into the DOM or Document Object Model already. The string "My Furry Kittens!" in this example would be available in the global variable document.title.
If you like, you could put a button into a plugin and let people push it to summarize the website. Or, they could just look up at the title. It is already on the page. Of course, if the goal is to scrape titles one can avoid writing a parser and use a "fake" headless scriptable browser like phantomJS or similar.
You can read more about document.title on the Mozilla Developer Network. MDN is a great reference for learning how web browsers work. They are the maintainers of the Mozilla Firefox browser. Most of what you can learn there will also work on Chrome, Internet Explorer, and various mobile platforms.
Good Luck!
How about implementing a local proxy server on the mobile device. The browser would just need to be configured to use the proxy, while the custom proxy implementation can transform the requested html however it likes.
I am building an online web application which offers clients to test their language skills.
The application consists of series of different test the clients can freely do. One of these tests is one where the client sees a sentence on the web-page and then is required to speak the sentence to a microphone. The idea would be to record the audio stream, send it to server and save it there to a file.
Is this possible using PHP, Java, or something similar to them?
Thank you for any help :)
I know you asked for PHP, I'm guessing that's your language of choice, but have you considered using html5 to record your audio? Note: browser support is still lacking but it might be worth looking into depending on your requirements.
Check out this tutorial; it uses the GETUSERMEDIA API to access you camera and microphone hardware.
Update: Here is another good tutorial on the subject.
The only realistic solutions for solving the problem are with flash, as suggested by another answer, or a java applet. In a year or two that will hopefully change and you'll be able to use javascript and HTML5, but this is now.
I would say this is a problem better and more easily solved with flash, but for java, You need to write a java applet to do the recording. Here are some hints to get you started:
http://docs.oracle.com/javase/tutorial/deployment/applet/
http://www.java2s.com/Tutorial/Java/0120__Development/CapturingAudiowithJavaSoundAPI.htm
http://www.jsresources.org/
You do not need java speech API or JMF, just java sound. You might WANT JMF to compress the audio file to make uploading go faster, but you can get this working without. Note that you may need to "sign" your applet in order to record audio in a browser.
If you are averse to flash, you could also use haxe to write your flash code.
Not 100% what you're looking for but I think it'll at least give you some ideas.
How to record streaming audio to the server
It is possible to solve this problem using Flash and Java both. You can use Flash component to record sound and send it in chunks to server side which can be implemented using java.
Pros to create sound recorder in Flash are many.
Flash is widely installed plugin in Browser
Java Applet gives warning before running it which many times turns off users.
Numerically checked, most media applications are created using Flash thereby providing you nice support.
Java Applets are used where thick client has to fit into browser and must also be secure. You will still find many real time treading applications are written in java applets.
Here are couple of tutorials to create Sound Recorder in Flash
http://active.tutsplus.com/tutorials/actionscript/create-a-useful-audio-recorder-app-in-actionscript-3/
Adobe record sound and save
This collected stream of sound can be stored in chunks on client side and can be synced with backend server(any server side language shall be fine.).
Implementing your server in Java has advantage. If tomorrow need arises, you can stream the same sound using Red5 server which is implemented in Java.
See more here: http://www.red5.org/
There is an audio recording SDK for this which is written in PHP, Flash and HTML5. http://recordmp3online.com
I am actually the author of that SDK (full disclosure)
I would like to know if the following can be done in flash/Java:
I have an ASP.NET web site from which I need to be able to print/send a specific set of instructions to a code-bar printer. Since this can't be done from javascript, I thought maybe a client side app/plugin (Flash, Java) could do it.
Do any of you know if this can be done? where can I find how to do it?
many thanks in advance!
It is possible to print in Java, for a website you could develop a Java applet. There is an official Java website available about printing which includes API documentation and tutorials. The only catch is because of the Java security model the applet needs to be signed.
Here is another link from Java about signing applets. Note that you are able to create your own signature (as opposed to having one from a certificate authority), it will just pop up a warning when the applet loads, which may be ok depending on the audience of your website.
I've been trying to understand how flash animations or a Java Applet work within a browser.
I can think of a couple of ways -
The Flash Player/Java Applet are machine code that's dynamically linked it, and given
some parameters about the area of the screen that belongs to them; after that, they
run within the same process space.
The browser exposes an API that the player/applet use to talk to it and they live
in a separate process. (Presumably they talk via sockets?) The API could correspond to
openGL/X11/some custom calls.
These possibilities still don't explain things like how a button click can make the
player full-screen, how it can play music, how it can inspect the DOM, etc. For that matter,
is the video displayed by decoding to a sequence of images, and rendering them
one at a time, or is there a more efficient way, e.g., of pushing the deltas in the image?
The Wikipedia page on Java Applets (1)
talks about how the applet is run in a sandbox (presumably a separate process), but
it doesn't say how the browser and the applet communicate.
Perhaps the answer depends on the underlying platform?
Any pointers to systematic discussion of this topic would be appreciated (as would
a reference to the APIs).
(My interest in this stems from an insatiable curiosity.)
I'm pretty sure plugins like Java applets and Flash run via NPAPI in most browsers. I looked into this matter myself some time ago and NPAPI was the answer I found.
In the case of browser and Java applets, the applets are typically run within the Java plugin, which runs as a separate process (you can see it e.g. in the task administrator in Windows).
The plugin creates an object for each applet in the DOM, and you can thus interact with the applet from Javascript. Anyway, calls to the applet that take a while to return do have the effect to freeze the browser, therefore I'd say the communication with the plugin runs in the same thread as the main refresh loop. This seems at least to be the case with Firefox.