如何解决java.lang.RuntimeException:存根! .java文件错误? [英] How to resolve java.lang.RuntimeException: Stub! error in .java file?

查看:556
本文介绍了如何解决java.lang.RuntimeException:存根! .java文件错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用在Weka GUI上创建的.model文件对实例进行分类.看来我已经成功对测试实例进行了分类,但是,我不确定是否能够成功加载我的.model文件和Stub编译器错误.

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.

我尝试删除了extends AppCompatActivity,如果这对.model上传有任何影响.事实证明,使用getAssets()时,代码必须在活动中.但是,我仍然不确定模型是否已上传以及异常的编译器错误.我遵循@davidmascharka的在GitHub上工作(他还在从资产中加载WEKA模型),但是我的代码无法编译.

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.

这是我的代码:

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();
        }
    }
}

这是我的错误输出:

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.

有什么想法吗?

谢谢.

推荐答案

之前可能已经介绍过,但是weka.jar 允许Stub实现.本质上,您必须将运行设置配置为"app",而不是特定文件.

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.

如果要查看特定文件的工作方式,则可以为应用程序使用debug选项.

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

这篇关于如何解决java.lang.RuntimeException:存根! .java文件错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆