虚拟机上eclipse和linux的java类路径问题

cczfrluj  于 2021-06-10  发布在  Hbase
关注(0)|答案(0)|浏览(283)

我在eclipse上有一些java代码,我想把它发送到运行linux命令行的虚拟机上。我正在通过mapr.com教程学习hbase,它告诉我一旦登录到虚拟机,就运行以下命令来运行程序:

java -cp `hbase classpath`:./lab-exercises-shopping-1.0.jar shopping.ShoppingCartApp setup

当我在适当的目录下运行时:

[user01@maprdemo target]$ java -cp `hbase classpath`:./lab-exercises-shopping-1.0.jar shopping.ShoppingCartApp setup

我得到这个错误: [user01@maprdemo target]$ java -cp 'hbase classpath':./lab-exercises-shopping-1.0.jar shopping.ShoppingCartApp setup Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2615) at java.lang.Class.getMethod0(Class.java:2856) at java.lang.Class.getMethod(Class.java:1668) at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.conf.Configuration at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 6 more 我相信,如果我错了,请告诉我 NoClassDefFoundError 意味着类是在编译时发现的,但不是在这里?但是我知道类在那里,因为在我的原始目录中(不确定是否有名称)。

ls lab-exercises-shopping/target:
classes      lab-exercises-shopping-1.0.jar   (among other things)

ls lab-exercises-shopping/target/classes/shopping:
dao   InitTables.class   model   ShoppingCartApp.class    ShoppingCartTool.class

键入时:hbase classpath:image1image2
我在这方面是相当新的,不知道我在说什么,但我正在努力学习,所以任何和所有的帮助是非常感谢。
另外,如果有人也能解释一些有帮助的事情:类路径和hbase类路径之间有区别吗?在哪里可以找到/all类路径?
更新:我在putty中做了完全相同的事情,但它做了一些不同的事情: WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Creating table... table created. Creating table... table created. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at shopping.ShoppingCartApp.main(ShoppingCartApp.java:32) pdf说明告诉我:注意:如果您看到以下警告消息,请按此处所示设置ld\u library\u path。warn util.nativecodeloader:无法为您的平台加载本机hadoop库。。。在适用的情况下使用内置java类info security.jnibasedunixgroupsmappingwithfallback:返回到基于shell的导出ld\u library\u path=/opt/mapr/hadoop/hadoop-0.20.2/lib/native/linuxamd64-64
因此,我尝试了该代码,并再次运行它,这有点帮助,但在下面的输出中,应该插入三行,而不是两行:

WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
 table already exists.
 table already exists.
in init ...
------------------------------
 Inserting rows in Inventory Table:
mkPut   [Inventory [key=pens, quantity=9]]
mkPut   [Inventory [key=notepads, quantity=21]]
2017-01-17 11:13:16,777 INFO  [main] client.HTable: BufferedMutator Use HBase ThreadPool
Exception in thread "main" java.lang.NullPointerException
        at org.apache.hadoop.hbase.client.HTable.getBufferedMutator(HTable.java:2349)
        at org.apache.hadoop.hbase.client.HTable.put(HTable.java:1311)
        at shopping.dao.InventoryDAO.addInventory(InventoryDAO.java:103)
        at shopping.ShoppingCartApp.saveInventoryTableData(ShoppingCartApp.java:89)
        at shopping.ShoppingCartApp.main(ShoppingCartApp.java:36)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题