file locked after youtube resumable upload java sdk - java

My java code did direct upload of a video and afterwards the program can move the file to a folder.
I have just change the code to do resumable upload but now after the upload the file cannot be moved. I can see, at least with jdk 7 on windows "Files.move", "file is being used by another process" -- (not exact message but similar). Also on mac lion with jdk6 I can confirm that file move does not work anymore but I cannot see error message because Files.move is available on jdk7 apparently.
I tried closing the file like this.
ms.getInputFileStream().close();
as well as this
new FileInputStream(ms.getMedaiFile()).close()
But no luck.
Can someone point me in the right direction?
The resumable code is essentially what is in the youtube api example/demo package.

Can you post the code in order to test this scenario? Maybe you can solve this problem in Java 7 with "try-with-resource".
See:
http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html
http://www.javaspecialists.eu/archive/Issue190.html

Related

Uploading App To Windows 10 Store

I have a few questions about uploading a app to the Windows 10 store. My question is, I code in Eclipse and I created a program in JAVA, can I still upload it???
Also, if the answer to that is Yes, when I went to https://msdn.microsoft.com/library/windows/apps/hh694062.aspx on one of the requirements, it said, Required (at least one package).
I might sound like a noob, but IDK what that means.
Also, heres my app that I want to add to the app store > http://www.mediafire.com/download/fm8nxv3wcmmclmo/Gadgets.jar
(this app still has bugs, I have a updated version but I have not added it to MediaFire yet).
Thanks guys!
You can't publish a Java app into windows 10 store, because .jar executables need Java so they are not compatible with the Windows store.

invocation of dll from java , edit dll source code

I am using an open source jar from github and its running ok. While using the library API the program pops a message box and waits for user to click the ok button. I checked it via debugger and apparently a dll file in the native directory gets invoked and it is responsible for the messagebox, after clicking ok the output is what excepted. I guess my question is how to skip this message box or alternatively how can I just programmaticaly click the ok button so the program wont be halted until clicking the button. I try editing the dll file but its a binary code, and there is no way to edit a jar file and and re-compile it to work again, so I'm kinda stuck.
I believe that if I can watch the source code I can change the function itself and it should work but im unable to pull this off. I understand that the dll file before compilation probably was written in C, C++ or C# so I guess the only problem is getting to the dll file itself. i don`t beleive a sample code is required here.
Thank you in advance!
To decompile/reverse-engineer the DLL (if written in C#), you can use the free .NET decompiler from JetBrains: dotPeek. If written in C/C++, it will be much harder to reverse engineer the DLL and I would recommend using some sort of test automation software. Ranorex is a good paid one, and SikuliX is a free one that can probably accomplish what you need.

How to change voice in FreeTTS - Java

I am running a program in java in which i use FreeTTS Voices, what i want is to change the voice.
when i run the program it shows:
"System property "mbrola.base" is undefined. Will not use MBROLA
voices."
I use the following code to speak up the text i want
Voice voice;
voice = voiceManager.getVoice(VOICENAME);
voice.allocate();
and then
voice.speak(t4.getText());
I tried to find tutorials to insert MBROLA voices. One of the tutorial i found was on their web page: http://freetts.sourceforge.net/mbrola/README.html but i am in windows not don't know anything of MAC therefore i am unable to know how to do it. Other tutorials were on Linux and i therefore even don't understand them. I am using netbeans on windows and i want someone to clearly explain me how to do this. I am a newbie and 14 year old.
If you look at the link you submitted, there's a big message that says: "NOTE: FreeTTS support for MBROLA on the Windows platform has been troublesome in the past, but appears to have been fixed by the MBROLA team. Please refer to the FreeTTS Forum for more information."
Here's a direct link to the forums: http://sourceforge.net/p/freetts/discussion/137669/thread/848a09ab
You have to specify the path to the mbrola folder, either by properties or directly via the code:
System.setProperty("mbrola.base", "c:/.../mbrola");
For more see e.g. FreeTTS mbrola not able to find path

Proper method to find user's My Documents folder on Windows with Java?

For whatever reason, I sometimes need to find the current user's My Documents folder on Windows in a Java program to read some files. But as far as I can tell, there is no way to do it that isn't severely flawed.
The first wrong way: System.getProperty("user.home");
Why it won't work:
It only returns the \username\ folder; I'd need to add "\Documents\" on to the end to get the Documents folder... and that only works in English.
Sun bugs 6519127 and 4787931. Java finds the user home folder on Windows by reading a deprecated registry key* to find the Desktop then taking the parent; this method has multiple known problems that will easily cause a completely wrong folder to be returned. The bugs are 3.75 years and 8 years old with no fix.
The second wrong way: Using a registry-reading program to get the Personal folder of the user, which is My Documents (but i18n'd).
Why it won't work:
While it fixes the English-only problem, it's still using the same deprecated registry area, so the bugs still apply to it.
The deprecated registry key says to use a native call (SHGetKnownFolderPath) which I obviously can't do from Java.
The third wrong way:
JFileChooser fr = new JFileChooser();
FileSystemView fw = fr.getFileSystemView();
File documents = fw.getDefaultDirectory();
Why it won't work: It works great!
Except when it doesn't. While I had a program that used this open and running in the background, I opened a DirectX game (Fallout: New Vegas). The Java program immediately terminated with no stack trace. Always reproducible (for me on that game, and who knows what else). Couldn't find a Sun bug#.
So is there any method to find a user's Documents folder, on Windows, from Java, that doesn't have known problems?
(This is a nice big question.)
*(The key is "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
There's no pure java way to do it, but you could use the JNA wrapper over JNI to do it without having to write any native code yourself. There's a good example of how to get the Documents folder on Windows halfway down the responses at:
What is the best way to find the users home directory in Java?
A time consuming, but reliable way of finding the 'Documents' folder of a windows user: Make your java app execute a bat script that uses Reg.exe (a windows system file) to find the value of the reg key which has the path in it. Then use a pipeline in the same bat file to send that data to the 'findstr' function which windows command prompt has. Use another pipeline to output the returned value to a text file. Then, simply make your java app read that text file, and delete it once its done :) Worked well enough for me.
Code for the bat file:
# echo off
Title Find Documents Folder
Reg Query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" |findstr "Personal">>DocPath.dat
exit
There is a custom Java API that someone built (their website no longer works), but there code remains on Google Code:
http://winfoldersjava.googlecode.com/files/WinFoldersJava_1.1.zip
There are two DLL's that need to be referenced, one for each architecture(x86 and x64).
user.home is not "my documents", but users home folder, like on Unix ~/.
To get to "My documents" you can use System.getProperty("user.home")+"\Documents"; irrespective of the language system. Try it.

Red5 RTMP Streaming

I'm very new to RTMP streaming and am seeking help. Just enough to get me started.
I have been Googling for about 5-7 hours now and still cannot determine my answer!
The documentation of Red5 is limited and cannot find any support at all! Even similar questions to mine are unanswered on stackoverflow :(
My questions are:
Why can't I simply place an .mp3
inside red5's server root and play
it?
To serve a simple MP3 file over
RTMP. Do I need to write a Java
application?
If so, any pointers?
To make matters worse, I have little to none Java experience.
Please help ST.
The easiest way to do what you want to is to install the oflaDemo. Start your red5 server and go to http://localhost:5080/installer
You need to select "oflaDemo" there and install it, if you don't already have it installed. Next place your mp3's or whatever in the following location
%RED5_HOME%/webapps/oflaDemo/streams
Red5 home will be the directory where you installed Red5. So if you used an installer it may look like this:
C:\Program Files\Red5\webapps\oflaDemo\streams
To play your mp3 without writing any code flash or java, next go to this url:
http://localhost:5080/demos/ofla_demo.html
Connect and select your file from the list and thats it.
I'm also playing with red5, and I've considered these two resources very helpful:
http://www.red5tutorials.net/index.php/Tutorials:Getting_Started_With_Red5_Server
http://trac.red5.org/wiki/Documentation/UsersReferenceManual/Red5CoreTechnologies/01-Creating-New-Applications#Chapter1.CreatenewapplicationsinRed5
have you got the Demos that come with RED5 installed? You won't have to code in java but you will have to open up a connection in flash in order to stream the mp3, the demos that comes with RED5 installation should have those examples.
I felt Wowza easier. There is a free version of Wowza which allows upto 10 connections. But after that you have start shelling money. But definitely lesser than FMS! And it is very easy. Just a few steps to setup and you can have your very own RTMP application streaming mp3 :) And if you do find the answer of how to stream RTMP on Red5, please do let me know!
for streaming an mp3 file you don't need any functionality of the red5 server, a webserver should be enough.
if you still have to load it from the red5 server:
is the file accessible in your browser? e.g. http://[red5-server]/file.mp3
then just use this url when loading the mp3 file in flash as this is not working i want to include url in my jsp how can i do that and what player i have to use

Categories