`

Linux下Could not find or load main class问题分析解决

阅读更多

        我将一个简单的本地JAVA文件上传到Linux下运行,发现报“Error: Could not find or load main class”,而我用java -version和javac -version都能正常显示JVM的版本号。而在另一台机器上却能正常运行。

        网上查资料说是classpath的问题,于是java -class . TheClassName或java -class TheCurrentDir TheClassName即可正常运行,所以基本能确认是classpath的问题,于是echo $CLASSPATH将两台机器的CLASSPATH打印出来,发现不能正确运行java TheClassName的机器少了“.:”,于是我先运行export CLASSPATH=.:$CLASSPATH,再执行java TheClassName正常。

 

附Linux和Windows下输出环境变量的区别:

        Linux下变量前量加上$符,而Windows则用两个%将变量夹起来,如shell下用echo $PATH输出path的值,windows的cmd下则是用echo %PATH%。

 

参考文章:http://stackoverflow.com/questions/7485670/error-could-not-find-or-load-main-class

分享到:
评论

相关推荐

    【SpringBoot】Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster

    【SpringBoot】Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster报错明细问题解决后记 报错明细 IDEA SpringBoot集成hadoop运行环境,,本地启动项目,GET请求接口触发...

    sqoop1.46和1.47

    目前版本有1.4.6和1.4.7两个jar包,启动Sqoop时,抛出异常:Error: Could not find or load main class .usr.local.sqoop-1.4.7.sqoop-1.4.7.jar 则可以下载资源将sqoop-1.4.7.jar放到sqoop的lib目录下重新启动,...

    sqoop-1.4.7.jar

    解决错误:Could not find or load main class org.apache.sqoop.Sqoop。把这个sqoop-1.4.7.jar放到sqoop根目录下的lib目录中,即可。 如果你没有积分,也可以自己去这个地址下载:...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - FIX Remaks panel focusing on main form (via PostMessage), since TreeInspector in FlexEditSE captures focus on self. - FIX Invalid arc size calculation when flex-control's size changes via DocRect ...

    eclipse 下打包

    的错误 <br>如果没有使用其他插件啊,类库等,以上的步骤就可以了 但如果用了,例如我用了SWT,就麻烦一点了 如果不作以下操作,会出现 Could not find the main class, Program will exit. 的错误。...

    Senfore_DragDrop_v4.1

    Linux and Kylix are not supported. There are *NO* plans to port the library to Kylix. The drag and drop protocols available on Linux are too much of a mess at this time. ----------------------------...

    CE中文版-启点CE过NP中文.exe

    Added the ModuleLoader class which can force load dll's Fixed endUpdate for the listview Thanks go out to SER[G]ANT for updating the russion translation files already June 23 2018:Cheat Engine 6.8.1...

    微软内部资料-SQL性能优化3

    Key range locks are similar to row locks on index keys (whether clustered or not). The locks are placed on individual keys rather than at the node level. The hash value consists of all the key ...

    Bayesian Network(贝叶斯网络) Python Program

    program will present each event to each input node and find out if the input node's filter matches the evidence. If it does match, that fact is printed to standard output, but nothing else is done. ...

    王小平版遗传算法的光盘源代码

    problem which shows you how to build a simple 2-class "dendritic" classifier (see my paper in the sfi account). You should not need to modify any of the other myriad files. COMPILING Source code ...

    Bochs - The cross platform IA-32 (x86) emulator

    class, optional commit support on Bochs exit, save/restore file attributes, 1.44 MB floppy support, set file modification date/time - converted the complete hdimage stuff to the new 'hdimage' ...

    gertt点阵图读取器(opengl)

    MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hInstance=NULL; // Set hInstance To NULL } } /* This Code Creates Our OpenGL Window. ...

    opengl画图程序附带源代码

    MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); hInstance=NULL; // Set hInstance To NULL } } /* This Code Creates Our OpenGL Window. Parameters Are: * * ...

    jquery-1.1.3 效率提高800%

    bar台北") $("div[@id=台北]")Escape Selectors: A frequently requested feature you can now select elements by ID (or other selector) that uses a special character, for example this will find the div ...

Global site tag (gtag.js) - Google Analytics