反射(问题:无法调用默认包下的类)

public class ttt {
    public static void main(String[] args) {
        int ret = 0;
        int ProgramID = 0;
        int AreaID = 0;
        int FileID = 0;
        String LedSystemIP;
        LedSystemIP = "192.168.1.101";
        MethodOfLED methodOfLED=new MethodOfLED();
        try {
            methodOfLED.AddTextArea(ProgramID, 
                    "EX File Program", 
                    30, 1, AreaID, 0, 0, 64, 64, 
                    "FileArea", 0, 0, 0, 0, FileID, 
                    "D:\\testled.rtf", 0, 5, 5, 0, 0, 0, LedSystemIP);
            methodOfLED.SendProgram(ret,LedSystemIP,0);
            methodOfLED.DeleteTheProgram(ret,ProgramID,LedSystemIP);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        

        /*try {
            //******************************************************************************************************
            // 实例1:   发送“文本”节目( 一个节目,一个区域,轮播)
            Class class1 = Class.forName("JavaLedFun");
            Method[] methods = class1.getMethods();
            for (Method method : methods) {
                System.out.println(method.getName());
                Class<?>[] parameterTypes=method.getParameterTypes();
                for(Class<?> parameterType:parameterTypes) {
                    System.out.println(parameterType.getName());
                }
            }
            
            java.lang.reflect.Method method = class1.getMethod("AddTextArea",
                    new Class<?>[] {int.class,String.class,
                    int.class,int.class,int.class,int.class,
                    int.class,int.class,int.class,String.class,
                    int.class,int.class,int.class,int.class,
                    int.class,String.class,int.class,int.class,
                    int.class,int.class,int.class,int.class,
                    String.class}
);
            Object class2=class1.newInstance();
            
            method.invoke(class2, 
                    new Object[] {ProgramID, 
                    "EX File Program", 
                    30, 1, AreaID, 0, 0, 64, 64, 
                    "FileArea", 0, 0, 0, 0, FileID, 
                    "D:\\testled.rtf", 0, 5, 5, 0, 0, 0, LedSystemIP});
            
            java.lang.reflect.Method method2=class1.getDeclaredMethod("SendProgram", new Class[] {String.class,int.class});
            ret = (Integer)(method2.invoke(class2, LedSystemIP,0));
            
            if(ret == 1)
            {
                System.out.println("Send Success !\n");
            }
            else
            {
                System.out.println("Send Failed !\n");
            }
            
            java.lang.reflect.Method method3=class1.getDeclaredMethod("DeleteTheProgram", new Class[] {int.class,String.class});
            ret = (Integer)(method3.invoke(class2, ProgramID,LedSystemIP));
            
            
            
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }catch (NoSuchMethodException e1) {
            e1.printStackTrace();
        }catch(IllegalAccessException e2) {
            e2.printStackTrace();
        }catch(Exception e3) {
            e3.printStackTrace();
        }*/
    }
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值