‎28-01-2016 02:04 PM
I am getting an error running the following Java codes when MEGA Windows Client is currently open or active, on the same machine/server:
MegaApplication myapp = new MegaApplication();
MegaEnvironment myenv = myapp.getEnvironments().get("D:\\Program Files (x86)\\MEGA\\Data Environment\\DEV_ENV");
myenv.setCurrentAdministrator("mega");
myenv.setCurrentPassword("megapassword");
MegaTransactions mtransactions = myenv.transactions();
MegaTransaction mytrans = mtransactions.create("Certification", "mega");
MegaRoot myroot = mytrans.getOwnedDatabase().open();
I am getting error at highlighted line above. I cannot get reference to a MegaTransaction instance with the following error:
Exception in thread "main" MEGA Error 0x80020009(MegaTransaction.Create) : The application has encountered an error.
If this problem persists contact technical support.
at com.mega.modeling.api.jni.MegaTransactionsJNI.Create(Native Method)
at com.mega.modeling.api.jni.MegaTransactionsProxy.create(Unknown Source)
at com.ace.test.SampleMegaConnection.main(SampleMegaConnection.java:24)
The program code is running without error, and I could retrieve and read MegaObjects from the repository whenever I log-out,and exit the MEGA Windows Client.
I used a MEGA admin user to access via API, and I used my Windows-authenticated account to login to MEGA Windows Client.
What is wrong with this code line:
MegaTransaction mytrans = mtransactions.create("Certification", "mega");
that I could not start accessing MEGA simultaneously?
Thank you in advanced.
ACE
Solved! Go to Solution.
‎04-02-2016 07:33 AM
Hi Gregory,
THANK YOU VERY MUCH!
It now works with empty String argument in getRoot()
MegaRoot root = session.getRoot("");
It seems that the password argument is not required.
Cheers,
ACE
‎03-02-2016 06:01 PM
‎02-02-2016 10:34 AM
Thank you, Greg. I found the javadoc for that getRoot() method as you mentioned. However, I still got the problem getting the reference to the MEGA root:
I have tried searching Google for MEGA Error 0x80010105, but I guess I did not find the right info.
Does MEGA have reference for all possible MEGA Error codes it generates to find clues on problems like this?
Thanks again.
Cheers,
ACE
‎01-02-2016 05:36 PM
The documentation is on the page for the MegaCurrentEnvironment interface.
Regards
Gregory
‎01-02-2016 02:54 PM
Thanks Greg!
I am able to detect whether MEGA session is currently open or not, but I tried using the password as argument but I am still getting same errors, and could not get reference to the MegaRoot:
Exception in thread "main" MEGA Error 0x80010105
at com.mega.modeling.api.jni.MegaCurrentEnvironmentJNI.getGetRoot(Native Method)
at com.mega.modeling.api.jni.MegaCurrentEnvironmentProxy.getRoot(Unknown Source)
at com.ace.test.SampleMegaConnection.main(SampleMegaConnection.java:44)
Where can I get that JavaDoc you mentioned? I attached javadoc for mj_api.jar on my Eclipse project... The following are what I am getting:
MegaCurrentSession's parent class- MegaCurrentEnvironmentProxy, where getRoot() method is inherited, does not have documentation:
I cannot find details for the inherited method: getRoot():
Can you please share where I could get the right documentation for MegaCurrentEnvironmentProxy.getRoot() method?
Thanks again for responding. I really appreciate this.
Regards,
ACE
‎29-01-2016 04:59 PM
Hi
No, this code works from outside MEGA too (MEGA must be running, if it is not the case this call will launch MEGA and display the connection dialog).
If you want to build a batch application it is better for you to use the MegaApplication class, you can run your application in a separate windows session to make sur no MEGA instance is running.
This function is documented in the javadoc:
MegaRoot getRoot(java.lang.String password)
‎29-01-2016 10:32 AM
@gquiniou wrote:Hi ACE,
You can only use MegaApplication when the MEGA Windows application is not running.
As an alternative you can use MegaCurrentSession to access the current session when MEGA is open:
MegaRoot myRoot = new MegaCurrentSession().getRoot("");Gregory
Hi Gregory,
Thanks for the response. Can you confirm: the code that you provided only works when the Java program containing that instruction is invoked (via some sort of Macro) from the current MEGA Windows application, right?
I am trying to develop a Java program that runs scheduled process of connecting to MEGA. This program must be able to processes some Mega Objects whether the MEGA Windows application is open or not.
Also, what's that empty String parameter here?
new MegaCurrentSession().getRoot("");
I tried checking for Java Documentation for MeagaCurrentSession class, unfortunately no JavaDoc is available.
ACE
‎28-01-2016 05:59 PM - edited ‎28-01-2016 06:06 PM
Hi ACE,
You can only use MegaApplication when the MEGA Windows application is not running.
As an alternative you can use MegaCurrentSession to access the current session when MEGA is open:
MegaRoot myRoot = new MegaCurrentSession().getRoot("");
Gregory