Friday, July 18, 2014

Error: opening registry key 'software javasoft java runtime environment'

I encountered this error when I tried to open the Android Device Monitor in Android Studio and it takes me two hours to tackle with it and I think I'll write down my thoughts.

I will summarize several methods to solve this problem from easy to complex:

1. First, if your Error looks like this:
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'\CurrentVersion'

has value 'X.X', but 'X.X' is required.
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

Then you could do steps as blow:
  1. Open Commend  Prompt, type "regedit" to open the Registry (be careful doing this)
  2. Go to "HKEY_LOCAL_MACHINE" on the left-hand side registry explorer/tree menu
  3. Click "SOFTWARE" within the "HKEY_LOCAL_MACHINE" registries
  4. Click "JavaSoft" within the "SOFTWARE" registries
  5. Click "Java Runtime Environment" within the "JavaSoft" list of registries
  6. Highlight "CurrentVersion" (should see it in the main registry key explorer window on the right)
  7. Change version to "x.x" (which you need)
If after doing this, the error became this:
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'

Then it means that you didn't have the CurrentVersion x.x installed or installed properly. So you need to install the correctly version from this website:  http://www.oracle.com/technetwork/java/javase/index.html

Don't forget to change your JAVA_HOME and your PATH after you install  the new JDK

2.  Second Error type (even without the CurrentVersion):
Error: Registry key 'Software\JavaSoft\Java Runtime Environment'
Error: could not find java.dll
Error: Could not find Java SE Runtime Environment.

The you need to do these steps:
  1. Open Commend  Prompt, type "java -version" to check if there is an error
  2. If you got the error as like above, then you need do to the Control Panel -> Uninstall a Program and then removed java.
  3. Then you need to Re-install Java, you can install java from the website: http://java.com/
  4. Re-install your JDK from this website: http://www.oracle.com/technetwork/java/javase/index.html, and you have better to install the latest version.
  5. At last, don't forget to change your JAVA_HOME and your PATH after you install  the new JDK
So if you still cannot solve the problem or you want to share your methods, please leave a message below.
At last, in case of some one don't know how to change the JAVA_HOME and PATH under windows (7/8), I will show you as below:
  1. Open Computer, and then click Computer (beside File on the lefttop).
  2. Click the System Properties.
  3. Click Advanced system settings on the left bar
  4. Under the Advanced tab, click Environment Variables...
    • Click New  to add a new variable name and value:, or click the existing variable, and then click Edit to change its name or value.
    variable name: JAVA_HOME Value: C:\Program Files\Java\jdk 1.7.0_65
    • System variables, find Path, then click edit:
    • add the codes in the end of Variable Value
    "C:\Program Files\Java\jdk1.7.0_65\bin"

Wednesday, July 2, 2014

How to Push Local File into Github

After we installed the Git Dash and have a account in Github I'll show you how to push your local file into your Github account(github.com):

1. Create a  new Repository in your github which you would like to push into;

2. Installed the Git Dash

3. Then we go back to the git dash, and go to the folder directory which the file located:
Quan@QuanQuan /d/github

I have go to my D:/github folder

4. Then we get our ssh key:
$ssh -keygen -t rsa -C "your email address"

and it'll tell where exactly our ssh key file in, usually it in the (c/user/username/.ssh/id_rsa) folder.
And then we do to the folder to find the file called: id_rsa.pub, we open it and copy the whole text, this text is basically our ssh key we should add it to our own github account.

5. Add ssh key to Github Account
Go to the Account Setting -> SSH KEYS -> Add SSH key -> paste the text into "key" field and name a title as you want.

6. After we add our ssh key successfully, we go back to Git Bash to check if our ssh key has been added:
$ssh -T git@github.com
Are you sure you want to continue connecting (yes/no)? (we type yes here)
Then you'll see "you've successfully Authenticated......"
7. Then we're going to use Git Bash to add the file into Github:
$ls
This is to check all the files
Such as we want push folder “TEST” into gihub, then we need to open that folder:
$cd TEST
Then we do next steps:
$git init
$git add .
(Add all the folders into staged area)
$git status

(check git status)
$git commit -m "initial commit"
(to add our fist comment for commit)
$git log
(to check the log of commit)
8. Now we can push these codes to Gihub:
$git remote add origin (here is the ssh url for your repository in Github)
(tell git I want to add a remote repository)
$git push origin master
(upload file)
9. Finally, refresh your repository in Github, we will see the files.
10. Some words in Github we need to know:
Branching: Allows you to create a separate working copy of you code with you have duplicate the project.
Merging: Allow you to merge branches together
Cloning: Other developers can get a copy of your code from a remote
Forking: Forking is not a git term, it's a term GitHub uses to promote social coding

Tuesday, July 1, 2014

Processing Exception: Ljavax/sound/sampled/AudioFormat;

Here is the exception in Processing when I wrote a small audio example for android:
debug:
FATAL EXCEPTION: Animation Thread
Process: processing.test.audioandroid, PID: 8961
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/sound/sampled/AudioFormat;
at processing.test.audioandroid.AudioAndroid$AudioThread.<init>(AudioAndroid.java:565)
at processing.test.audioandroid.AudioAndroid$Maxim.<init>(AudioAndroid.java:101)
at processing.test.audioandroid.AudioAndroid.setup(AudioAndroid.java:44)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.sound.sampled.AudioFormat" on path: DexPathList[[zip file "/data/app/processing.test.audioandroid-2.apk"],nativeLibraryDirectories=[/data/app-lib/processing.test.audioandroid-2, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 7 more
Suppressed: java.lang.ClassNotFoundException: javax.sound.sampled.AudioFormat
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 8 more
Caused by: java.lang.NoClassDefFoundError: Class "Ljavax/sound/sampled/AudioFormat;" not found
... 12 more

The reason for this is that I should use "android_api" for Maxim, instead of using 'MaximJava_api' , which is the reason that it doesn't work on android device.