How to resolve java.lang.RuntimeException: Stub! error in .java file?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I am trying to classify an instance using a .model file which I have created on the Weka GUI. It seems I have successfully classified the test instance, however, I am not sure whether I am able to successfully load my .model file and of the Stub compiler error.



I have tried to remove the extends AppCompatActivity and if that makes any difference in the .model upload. It turns out that to use getAssets(), the code must be in an activity. However, I an still unsure of whether the model has upload and the unusual compiler error. I have followed the basic framework of @davidmascharka's work on GitHub (he's also loading a WEKA model from assets), but mine does not compile.



Here's my code:



package com.example.owner.introductoryapplication;

import android.support.v7.app.AppCompatActivity;

import weka.classifiers.Classifier;
import weka.classifiers.rules.DecisionTable;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instances;

import java.util.ArrayList;

public class Test extends AppCompatActivity {
public static void main(String args) {
Test test = new Test();
test.start();
}

public void start() {
//LOADS THE MODEL...------------------------------------------------------
String rootPath = "/assets/";
String fileName = "PGBD_DecisionTableUPD.model";
Classifier cls = null;
try {
//cls = (Classifier) weka.core.SerializationHelper.read(rootPath + fileName);
cls = (DecisionTable) weka.core.SerializationHelper.read(getAssets().open(fileName));
} catch (Exception e) {
e.printStackTrace();
}
}
}


And here's my error output:



Exception in thread "main" java.lang.RuntimeException: Stub!
at android.content.Context.<init>(Context.java:67)
at android.content.ContextWrapper.<init>(ContextWrapper.java:30)
at android.view.ContextThemeWrapper.<init>(ContextThemeWrapper.java:40)
at android.app.Activity.<init>(Activity.java:643)
at android.support.v4.app.SupportActivity.<init>(ComponentActivity.java:46)
at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:68)
at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:62)
at com.example.owner.introductoryapplication.Test.<init>(Test.java:13)
at com.example.owner.introductoryapplication.Test.main(Test.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

Process finished with exit code 1


I expect the program to at least compile! I have absolutely no clue why it's not. I tried switching the order of my dependencies, hoping that would make a difference, but to no luck.



Any ideas?



Thanks in advance.










share|improve this question























  • This question in being asked already stackoverflow.com/questions/8982631/…

    – rishav prasher
    Jan 4 at 9:35













  • Hope this will help

    – rishav prasher
    Jan 4 at 9:37











  • @rishavprasher Thanks for the link. It mentions that I should run this on Android emulator or directly on the device, but I am simply printing it using System.out not on device screen.

    – Shounak Ray
    Jan 4 at 9:40













  • your welcome @Shounak Ray

    – rishav prasher
    Jan 4 at 9:41











  • @rishavprasher So I can't use that to solve my problem...!

    – Shounak Ray
    Jan 4 at 18:18


















2















I am trying to classify an instance using a .model file which I have created on the Weka GUI. It seems I have successfully classified the test instance, however, I am not sure whether I am able to successfully load my .model file and of the Stub compiler error.



I have tried to remove the extends AppCompatActivity and if that makes any difference in the .model upload. It turns out that to use getAssets(), the code must be in an activity. However, I an still unsure of whether the model has upload and the unusual compiler error. I have followed the basic framework of @davidmascharka's work on GitHub (he's also loading a WEKA model from assets), but mine does not compile.



Here's my code:



package com.example.owner.introductoryapplication;

import android.support.v7.app.AppCompatActivity;

import weka.classifiers.Classifier;
import weka.classifiers.rules.DecisionTable;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instances;

import java.util.ArrayList;

public class Test extends AppCompatActivity {
public static void main(String args) {
Test test = new Test();
test.start();
}

public void start() {
//LOADS THE MODEL...------------------------------------------------------
String rootPath = "/assets/";
String fileName = "PGBD_DecisionTableUPD.model";
Classifier cls = null;
try {
//cls = (Classifier) weka.core.SerializationHelper.read(rootPath + fileName);
cls = (DecisionTable) weka.core.SerializationHelper.read(getAssets().open(fileName));
} catch (Exception e) {
e.printStackTrace();
}
}
}


And here's my error output:



Exception in thread "main" java.lang.RuntimeException: Stub!
at android.content.Context.<init>(Context.java:67)
at android.content.ContextWrapper.<init>(ContextWrapper.java:30)
at android.view.ContextThemeWrapper.<init>(ContextThemeWrapper.java:40)
at android.app.Activity.<init>(Activity.java:643)
at android.support.v4.app.SupportActivity.<init>(ComponentActivity.java:46)
at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:68)
at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:62)
at com.example.owner.introductoryapplication.Test.<init>(Test.java:13)
at com.example.owner.introductoryapplication.Test.main(Test.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

Process finished with exit code 1


I expect the program to at least compile! I have absolutely no clue why it's not. I tried switching the order of my dependencies, hoping that would make a difference, but to no luck.



Any ideas?



Thanks in advance.










share|improve this question























  • This question in being asked already stackoverflow.com/questions/8982631/…

    – rishav prasher
    Jan 4 at 9:35













  • Hope this will help

    – rishav prasher
    Jan 4 at 9:37











  • @rishavprasher Thanks for the link. It mentions that I should run this on Android emulator or directly on the device, but I am simply printing it using System.out not on device screen.

    – Shounak Ray
    Jan 4 at 9:40













  • your welcome @Shounak Ray

    – rishav prasher
    Jan 4 at 9:41











  • @rishavprasher So I can't use that to solve my problem...!

    – Shounak Ray
    Jan 4 at 18:18














2












2








2


2






I am trying to classify an instance using a .model file which I have created on the Weka GUI. It seems I have successfully classified the test instance, however, I am not sure whether I am able to successfully load my .model file and of the Stub compiler error.



I have tried to remove the extends AppCompatActivity and if that makes any difference in the .model upload. It turns out that to use getAssets(), the code must be in an activity. However, I an still unsure of whether the model has upload and the unusual compiler error. I have followed the basic framework of @davidmascharka's work on GitHub (he's also loading a WEKA model from assets), but mine does not compile.



Here's my code:



package com.example.owner.introductoryapplication;

import android.support.v7.app.AppCompatActivity;

import weka.classifiers.Classifier;
import weka.classifiers.rules.DecisionTable;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instances;

import java.util.ArrayList;

public class Test extends AppCompatActivity {
public static void main(String args) {
Test test = new Test();
test.start();
}

public void start() {
//LOADS THE MODEL...------------------------------------------------------
String rootPath = "/assets/";
String fileName = "PGBD_DecisionTableUPD.model";
Classifier cls = null;
try {
//cls = (Classifier) weka.core.SerializationHelper.read(rootPath + fileName);
cls = (DecisionTable) weka.core.SerializationHelper.read(getAssets().open(fileName));
} catch (Exception e) {
e.printStackTrace();
}
}
}


And here's my error output:



Exception in thread "main" java.lang.RuntimeException: Stub!
at android.content.Context.<init>(Context.java:67)
at android.content.ContextWrapper.<init>(ContextWrapper.java:30)
at android.view.ContextThemeWrapper.<init>(ContextThemeWrapper.java:40)
at android.app.Activity.<init>(Activity.java:643)
at android.support.v4.app.SupportActivity.<init>(ComponentActivity.java:46)
at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:68)
at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:62)
at com.example.owner.introductoryapplication.Test.<init>(Test.java:13)
at com.example.owner.introductoryapplication.Test.main(Test.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

Process finished with exit code 1


I expect the program to at least compile! I have absolutely no clue why it's not. I tried switching the order of my dependencies, hoping that would make a difference, but to no luck.



Any ideas?



Thanks in advance.










share|improve this question














I am trying to classify an instance using a .model file which I have created on the Weka GUI. It seems I have successfully classified the test instance, however, I am not sure whether I am able to successfully load my .model file and of the Stub compiler error.



I have tried to remove the extends AppCompatActivity and if that makes any difference in the .model upload. It turns out that to use getAssets(), the code must be in an activity. However, I an still unsure of whether the model has upload and the unusual compiler error. I have followed the basic framework of @davidmascharka's work on GitHub (he's also loading a WEKA model from assets), but mine does not compile.



Here's my code:



package com.example.owner.introductoryapplication;

import android.support.v7.app.AppCompatActivity;

import weka.classifiers.Classifier;
import weka.classifiers.rules.DecisionTable;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instances;

import java.util.ArrayList;

public class Test extends AppCompatActivity {
public static void main(String args) {
Test test = new Test();
test.start();
}

public void start() {
//LOADS THE MODEL...------------------------------------------------------
String rootPath = "/assets/";
String fileName = "PGBD_DecisionTableUPD.model";
Classifier cls = null;
try {
//cls = (Classifier) weka.core.SerializationHelper.read(rootPath + fileName);
cls = (DecisionTable) weka.core.SerializationHelper.read(getAssets().open(fileName));
} catch (Exception e) {
e.printStackTrace();
}
}
}


And here's my error output:



Exception in thread "main" java.lang.RuntimeException: Stub!
at android.content.Context.<init>(Context.java:67)
at android.content.ContextWrapper.<init>(ContextWrapper.java:30)
at android.view.ContextThemeWrapper.<init>(ContextThemeWrapper.java:40)
at android.app.Activity.<init>(Activity.java:643)
at android.support.v4.app.SupportActivity.<init>(ComponentActivity.java:46)
at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:68)
at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:62)
at com.example.owner.introductoryapplication.Test.<init>(Test.java:13)
at com.example.owner.introductoryapplication.Test.main(Test.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

Process finished with exit code 1


I expect the program to at least compile! I have absolutely no clue why it's not. I tried switching the order of my dependencies, hoping that would make a difference, but to no luck.



Any ideas?



Thanks in advance.







java compiler-errors weka assets stub






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 4 at 9:23









Shounak RayShounak Ray

937




937













  • This question in being asked already stackoverflow.com/questions/8982631/…

    – rishav prasher
    Jan 4 at 9:35













  • Hope this will help

    – rishav prasher
    Jan 4 at 9:37











  • @rishavprasher Thanks for the link. It mentions that I should run this on Android emulator or directly on the device, but I am simply printing it using System.out not on device screen.

    – Shounak Ray
    Jan 4 at 9:40













  • your welcome @Shounak Ray

    – rishav prasher
    Jan 4 at 9:41











  • @rishavprasher So I can't use that to solve my problem...!

    – Shounak Ray
    Jan 4 at 18:18



















  • This question in being asked already stackoverflow.com/questions/8982631/…

    – rishav prasher
    Jan 4 at 9:35













  • Hope this will help

    – rishav prasher
    Jan 4 at 9:37











  • @rishavprasher Thanks for the link. It mentions that I should run this on Android emulator or directly on the device, but I am simply printing it using System.out not on device screen.

    – Shounak Ray
    Jan 4 at 9:40













  • your welcome @Shounak Ray

    – rishav prasher
    Jan 4 at 9:41











  • @rishavprasher So I can't use that to solve my problem...!

    – Shounak Ray
    Jan 4 at 18:18

















This question in being asked already stackoverflow.com/questions/8982631/…

– rishav prasher
Jan 4 at 9:35







This question in being asked already stackoverflow.com/questions/8982631/…

– rishav prasher
Jan 4 at 9:35















Hope this will help

– rishav prasher
Jan 4 at 9:37





Hope this will help

– rishav prasher
Jan 4 at 9:37













@rishavprasher Thanks for the link. It mentions that I should run this on Android emulator or directly on the device, but I am simply printing it using System.out not on device screen.

– Shounak Ray
Jan 4 at 9:40







@rishavprasher Thanks for the link. It mentions that I should run this on Android emulator or directly on the device, but I am simply printing it using System.out not on device screen.

– Shounak Ray
Jan 4 at 9:40















your welcome @Shounak Ray

– rishav prasher
Jan 4 at 9:41





your welcome @Shounak Ray

– rishav prasher
Jan 4 at 9:41













@rishavprasher So I can't use that to solve my problem...!

– Shounak Ray
Jan 4 at 18:18





@rishavprasher So I can't use that to solve my problem...!

– Shounak Ray
Jan 4 at 18:18












1 Answer
1






active

oldest

votes


















1














This may have been covered before, but weka.jar only allows for Stub implementations. Essentially, you must configure the run setting to "app" instead of a specific file.



If you want to see how a specific file works, then you can use the debug option for your app.






share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54036101%2fhow-to-resolve-java-lang-runtimeexception-stub-error-in-java-file%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    This may have been covered before, but weka.jar only allows for Stub implementations. Essentially, you must configure the run setting to "app" instead of a specific file.



    If you want to see how a specific file works, then you can use the debug option for your app.






    share|improve this answer






























      1














      This may have been covered before, but weka.jar only allows for Stub implementations. Essentially, you must configure the run setting to "app" instead of a specific file.



      If you want to see how a specific file works, then you can use the debug option for your app.






      share|improve this answer




























        1












        1








        1







        This may have been covered before, but weka.jar only allows for Stub implementations. Essentially, you must configure the run setting to "app" instead of a specific file.



        If you want to see how a specific file works, then you can use the debug option for your app.






        share|improve this answer















        This may have been covered before, but weka.jar only allows for Stub implementations. Essentially, you must configure the run setting to "app" instead of a specific file.



        If you want to see how a specific file works, then you can use the debug option for your app.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 4 at 16:25

























        answered Mar 31 at 17:28









        Shounak RayShounak Ray

        937




        937
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54036101%2fhow-to-resolve-java-lang-runtimeexception-stub-error-in-java-file%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas