當前位置:首頁 » 操作系統 » the7源碼

the7源碼

發布時間: 2023-04-02 09:10:21

1. Struts的資源文件時如何初始化的--struts源碼學習 - 輪上飛 - BlogJa...

[2]系統是如何啟動和初始化struts的在Web.xml中有這么一段代碼: action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml debug 3 detail 3 0 startThread com.cgogo.ypindex.StartThread startParam 2 1 action *.do 在web.xml中會配置struts的中央控制器類。Web.xml配置文件的初始化是由容器來實現載入和初始化的。如果你使用的是知凳tomcat的話,那麼就是由tomcat在啟動的時候會載入此web.xml文件,也就為此web應用創建了一個web Context,此context也就是你Web應用的訪問入口。載入中央控制器org.apache.struts.action.ActionServlet,這是一個Servlet,那麼,其就要進行螞判servlet的初始化操作。此action是如何對Struts系統進行初始化的呢?[3]init()--ActionServlet如何初始化Struts系統?看一下ActionServlet的源代碼:我們知道,在一個Servlet中,在其啟動的時候,首先要執行init()方法,那麼我們搭物旅先來看一下actionServlet的init()方法的源代碼: /** * Initialize this servlet. Most of the processing has been factored into * support methods so that you can override particular functionality at a * fairly granular level. * * @exception ServletException if we cannot configure ourselves correctly */ public void init() throws ServletException { // Wraps the entire initialization in a try/catch to better handle // unexpected exceptions and errors to provide better feedback // to the developer try {(1) initInternal();(2) initOther();(3) initServlet(); getServletContext().setAttribute(Globals.ACTION_SERVLET_KEY, this);(4) initMoleConfigFactory(); // Initialize moles as needed MoleConfig moleConfig = initMoleConfig("", config);(5) initMoleMessageResources(moleConfig);(6) initMoleDataSources(moleConfig);(7) initMolePlugIns(moleConfig); moleConfig.freeze();(8) 初始化配置參數 Enumeration names = getServletConfig().getInitParameterNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); if (!name.startsWith("config/")) { continue; } String prefix = name.substring(6); moleConfig = initMoleConfig (prefix, getServletConfig().getInitParameter(name)); initMoleMessageResources(moleConfig); initMoleDataSources(moleConfig); initMolePlugIns(moleConfig); moleConfig.freeze(); } this.initMolePrefixes(this.getServletContext()); this.destroyConfigDigester(); } catch (UnavailableException ex) { throw ex; } catch (Throwable t) { // The follow error message is not retrieved from internal message // resources as they may not have been able to have been // initialized log.error("Unable to initialize Struts ActionServlet e to an " + "unexpected exception or error thrown, so marking the " + "servlet as unavailable. Most likely, this is e to an " + "incorrect or missing library dependency.", t); throw new UnavailableException(t.getMessage()); } } 先來看一下初始化(1)的部分initInternal()。 [4] initInternal()--內部資源文件的初始化initInternal()就是實現內部資源文件的初始化的,也就是轉為Struts系統本身提供的以下錯誤信息提示等文字的國際化實現的。我們看一下源代碼是如何實現的: /** *. * *@ */ protectedvoidinitInternal() throwsServletException { // :FIXME: Document UnavailableException try{ internal= MessageResources.getMessageResources(internalName); } catch(MissingResourceException e) { log.error("Cannot load internal resources from 『"+ internalName+ "『", e); thrownewUnavailableException ("Cannot load internal resources from 『"+ internalName+ "『"); } }Struts根據配置文件的名字得到一個資源文件。internalName就是內部資源文件的名稱,其在actionServlet中定義: /** *. *@sinceStruts1.1 */ protectedString internalName= "org.apache.struts.action.ActionResources";取得後的對象是一個MessageResources的對象,保存在internal中, /** * The resources object for our internal resources. */ protected MessageResources internal = null;經過此初始化後,internal就不在是null了。至此就實現完成了內部資源文件的初始化。 /** * Initialize other global characteristics of the controller servlet. * * @exception ServletException if we cannot initialize these resources */ protected void initOther() throws ServletException { String value = null; value = getServletConfig().getInitParameter("config"); if (value != null) { config = value; } // Backwards compatibility for form beans of java wrapper classes // Set to true for strict Struts 1.0 compatibility value = getServletConfig().getInitParameter("convertNull"); if ("true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value) || "on".equalsIgnoreCase(value) || "y".equalsIgnoreCase(value) || "1".equalsIgnoreCase(value)) { convertNull = true; } if (convertNull) { ConvertUtils.deregister(); ConvertUtils.register(new BigDecimalConverter(null), BigDecimal.class); ConvertUtils.register(new BigIntegerConverter(null), BigInteger.class); ConvertUtils.register(new BooleanConverter(null), Boolean.class); ConvertUtils.register(new ByteConverter(null), Byte.class); ConvertUtils.register(new CharacterConverter(null), Character.class); ConvertUtils.register(new DoubleConverter(null), Double.class); ConvertUtils.register(new FloatConverter(null), Float.class); ConvertUtils.register(new IntegerConverter(null), Integer.class); ConvertUtils.register(new LongConverter(null), Long.class); ConvertUtils.register(new ShortConverter(null), Short.class); } }然後就執行(3)initServlet(); [6] initServlet()--如何初始化servlet這個初始化主要是初始化servlet的,哪些servlet呢? /** * Initialize the servlet mapping under which our controller servlet * is being accessed. This will be used in the &html:form * tag to generate correct destination URLs for form submissions. * * @throws ServletException if error happens while scanning web.xml */ protected void initServlet() throws ServletException { // Remember our servlet name //這里保存當前的servlet名字,保存在actionServlet的servletName屬性中 this.servletName = getServletConfig().getServletName(); // Prepare a Digester to scan the web application deployment descriptor Digester digester = new Digester(); digester.push(this); digester.setNamespaceAware(true); digester.setValidating(false); // Register our local of the DTDs that we can find for (int i = 0; i < registrations.length; i += 2) { URL url = this.getClass().getResource(registrations[i+1]); if (url != null) { digester.register(registrations[i], url.toString()); } } // Configure the processing rules that we need digester.addCallMethod("web-app/servlet-mapping", "addServletMapping", 2); digester.addCallParam("web-app/servlet-mapping/servlet-name", 0); digester.addCallParam("web-app/servlet-mapping/url-pattern", 1); // Process the web application deployment descriptor if (log.isDebugEnabled()) { log.debug("Scanning web.xml for controller servlet mapping"); } //取得當前的配置文件 InputStream input = getServletContext().getResourceAsStream("/WEB-INF/web.xml"); if (input == null) { log.error(internal.getMessage("configWebXml")); throw new ServletException(internal.getMessage("configWebXml")); } try { //解析當前配置文件digester.parse(input); } catch (IOException e) { log.error(internal.getMessage("configWebXml"), e); throw new ServletException(e); } catch (SAXException e) { log.error(internal.getMessage("configWebXml"), e); throw new ServletException(e); } finally { try { //

2. 求C++小游戲源代碼啊~

一個戀愛小測試賊靈驗哦
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,a,b,c,d,e,f,g,h,i,j,k,l,sum;
cout<<"歡迎來到戀愛指數測試器*>-<*"<<endl;
for(int i=1;i<=1000000000;i++)
l=i;
cout<<"獨家的哦*^0^*"<<endl;
for(int i=1;i<=1000000000;i++)
l=i;
cout<<"以下異性均為合適年齡"<<endl;
for(int i=1;i<=1000000000;i++)
l=i;
cout<<"下列問題如果是則輸入2,如果不是則輸入1,一點也沒感覺輸入0"<<endl;
for(int i=1;i<=1000000000;i++)
l=i;
cout<<"加油,面對你自己!*-o-*"<<endl;
for(int i=1;i<=1000000000;i++)
l=i;
cout<<"question one:"<<"你是否面對異性時有莫名心跳?"<<endl;
cin>>n;
cout<<endl;
cout<<"question two:"<<"你是否有看到異性被撩時很憤怒?"<<endl;
cin>>m;
cout<<endl;
cout<<"question three:"<<"你是否懼怕見到一位異性的家長"<<endl;
cin>>a;
cout<<endl;
cout<<"question four:"<<"你是否經常刷一位異性的QQ或其他軟體"<<endl;
cin>>b;
cout<<endl;
cout<<"question five:"<<"想不想真心和Ta用情頭?"<<endl;
cin>>c;
cout<<endl;
cout<<"question six:"<<"和Ta邂逅過嗎?"<<endl;
cin>>d;
cout<<endl;
cout<<"question seven:"<<"吃過同一個飯碗里的東西嗎?"<<endl;
cin>>e;
cout<<endl;
cout<<"question eight:"<<"有過一個人在夢里與Ta相遇嗎?"<<endl;
cin>>f;
cout<<endl;
cout<<"question nine:"<<"有為了等Ta一個人站在風雨中嗎?"<<endl;
cin>>g;
cout<<endl;
cout<<"question ten:"<<"想kissTa不,想摸Ta的頭發嗎?"<<endl;
cin>>h;
cout<<endl;
sum=n+m+a+b+c+d+e+f+g+h;
cout<<"正在測評中,請稍後..."<<endl;
for(int i=1;i<=1000000000;i++)
l=i;
if(sum>=16&&sum<=20)
cout<<"你的戀愛指數為:A。你是一個深深愛著Ta的人,你往往會走到最後^-^。"<<endl;
if(sum<=15&&sum>=12)
cout<<"你的戀愛指數為:B。你是一個矛盾卻又不失愛意的人,你的愛往往一波三折!-!。"<<endl;
if(sum<=11&&sum>=7)
cout<<"你的戀愛指數為:C。你是一個有點點情絲的人,你想表,卻又懼怕現實,你仍須努力o-o。"<<endl;
if(sum<=6&&sum>=0)
cout<<"你的戀愛指數為:D。你是一個無暇無垢,不食人間煙火的人,想一路踏歌,證道路上需佳人陪伴+-+。"<<endl;
if(sum>20||sum<0)
cout<<"你出格了喲ooo.ooo"<<endl;
cout<<"人生在世,恍如昨世,孤獨的身影終難走遠,你的那個Ta就在不遠方,就如漫天繁星,總有一顆屬於你!"<<endl;\
cout<<"快抓緊你身邊的那個Ta^-^oooooo"<<endl;
cout<<endl;
cout<<"作品創造者:yang sky one"<<endl;
cout<<"戀愛指數測試器已關閉,需重啟………………"<<endl;
return 0;
}

3. 源碼打包apk使用RecyclerView時遇到的坑

最近在做一個系統通知欄的項目叫MsgCenter。使用Android studio開發的.
使用了腳本拷貝與復制

LIBS="/Users/love/Desktop/moran2/MsgCenter/app/libs"
SRC="/Users/love/Desktop/moran2/MsgCenter/app/src/main/java/*"
RES="/Users/love/Desktop/moran2/MsgCenter/app/src/main/res"

ANDROIDMANIFEST="app/src/main/AndroidManifest.xml"

DES="/Users/love/Desktop/moran2/MsgCenter/MsgCenter"

mkdir -p $DES/src

cp -r LIBS DES
cp -r SRC DES/src
cp -r RES DES
cp -r JNI DES
cp ANDROIDMANIFEST DES
cp ANDROIDMK DES
然後提交到伺服器打包報錯:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.imoran.notification.lib, PID: 2630
java.lang.ExceptionInInitializerError
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115)
at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32)
at android.app.ActivityThread.handleBindService(ActivityThread.java:3158)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5795) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724)
Caused by: android.view.InflateException: Binary XML file line #7: Binary XML file line #7: Error inflating class android.support.v7.widget.RecyclerView
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class android.support.v7.widget.RecyclerView at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:423) at android.view.LayoutInflater.inflate(LayoutInflater.java:374) at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.(NotificationWindowManager.java:123) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.(NotificationWindowManager.java:34) at net.imoran.notification.lib.windowmanager.NotificationWindowManager .<clinit>(NotificationWindowManager.java:111)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115)
at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32)
at android.app.ActivityThread.handleBindService(ActivityThread.java:3158)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5795) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R styleable;
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:590)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:551)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R styleable" on path: DexPathList[[zip file "/flysystem/app/mor-notification.apk"],nativeLibraryDirectories=[/system/lib64/mor-notification, /flysystem/app/mor-notification.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:590)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:551)
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at net.imoran.notification.lib.manager.NotificationManager.initRootView(NotificationManager.java:51)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.initAdapterView(NotificationWindowManager.java:200)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:123)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager.<init>(NotificationWindowManager.java:34)
at net.imoran.notification.lib.windowmanager.NotificationWindowManager .(NotificationWindowManager.java:111) at net.imoran.notification.lib.windowmanager.NotificationWindowManager.getInstance(NotificationWindowManager.java:115) at net.imoran.notification.lib.service.StarStatusService.onBind(StarStatusService.java:32) at android.app.ActivityThread.handleBindService(ActivityThread.java:3158) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5795)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit MethodAndArgsCaller.run(ZygoteInit.java:834) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:724) Suppressed: java.lang.ClassNotFoundException: android.support.v7.recyclerview.R styleable
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 28 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
07-20 14:14:31.557 2630-2664/net.imoran.notification.lib I/System: FinalizerDaemon: finalize objects = 2695

從log中我們可以看到,
1.Binary XML file line #22: Binary XML file line #39: Error inflating class android.support.v7.widget.RecyclerView

2.同時還有這樣的 java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R$styleable

3.Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R$styleable"

一開始只注意到了第一點,於是在網路上查呀查:
就發現大家的說法就是 在eclipse或者android studio上 因為sdk的版本不match,等等的。有的人說把android.support.v7.recyclerview.jar這個包換掉,換成match的版本的就好了,但我這邊因為開發方式不一樣,就又斷掉了。但是卻讓我知道了是版本的問題

後來
有的人說是
1.AndroidManifest.xml中的targetSDKVersion不對,fix -> NOK。
2.build.gradle中的某些屬性不對。fix -> NOK

因為App是獨立的apk,就去這5.0,6.0 andorid 的源碼中去找android.support.v7.recyclerview.

同時又注意到了這兩點錯誤
2.同時還有這樣的 java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/recyclerview/R$styleable

3.Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.recyclerview.R$styleable"

從Log中我們可以看到
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:440)
at android.support.v7.widget.RecyclerView.<init>(RecyclerView.java:409)
RecyclerView的409 和 440 行出錯

就發現了在 frameworks/support/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java中

使用到了R.styleable.RecyclerView這個屬性,而第2,3點log中出現的就是R$styleable 的錯誤。

明確了:在android6.0版本RecyclerView類中用到了R.styleable.RecyclerView這個資源。而android5.0的版本中的RecyclerView類沒用到R.styleable.RecyclerView

回到frameworks/support/v7/recyclerview/目錄下就會發現
-----------5.0 沒有res/ 文件夾
-----------6.0 則有

那麼現在中場總結一下,因為andorid5.0中的RexyclerView類中沒有使用res資源,而6.0卻使用了。同時6.0的res/資源是存在的。只能說明,我們沒有引用到,或者說是沒有把對應的資源載入,進行編譯

問題又來了:res/資源是在哪裡載入的?

----------》 Android.mk 文件下有這么一段

發現了android-support-v7-recyclerview的身影

那這內容是什麼意思?

1.LOCAL_STATIC_JAVA_LIBARIES 本地靜態java庫。
2.LOCAL_RESOURCE_DIR 本地資源文件,默認是proct package和device package下面相應的res路徑和$(LOCAL_PATH)/res
3.LOCAL_AAPT_FLAGS += -c ldpi -c mdpi
上面指定了編譯時打包 ldpi 和mdpi 如果系統默認的是hdpi的話,那就是這三種都會裝入包中

在中場總結的時候,已經明確,是因為res資源沒有載入。
所以只需要在LOCAL_RESOURCE_DIR中加上frameworks/support/v7/recyclerview/res就可以了

Android.mk文件內容變成:

再次編譯,正常運行。

======================================================================================================
其實就是因為android的版本升級,RecyclerView 中的創建LayoutManager的方式發生了改變,舊版本里少了個 R.styleable.RecyclerView, 而在新環境下又沒將其編譯進去,故有此錯。

各位少俠也可以在 package 中的res/attrs.xml 下面自己定義一個`````

總體來說將的不是很清楚, 還請大家見諒 。。

4. 求Java 日歷的小程序的源代碼

當在一段代碼塊定義一個變數時,Java就在棧中 為這個變數分配內存空間,當該變數退出該作用域後,Java會自動釋放掉為該變數所分配的內存空間,該內存空間可以立即被另作他用。

Java內存分配中的堆

堆內存用來存放由new創建的對象和數組。 在堆中分配的內存,由Java虛擬機的自動垃圾回收器來管理。

5. 編譯android 源碼需要sdk環境嗎

下面是android學習手冊,可以查看編譯源碼,360手機助手中下載,

編譯環境:ubuntu9.10,widnows平台目前不被支持。

1)安裝必要的軟體環境

$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

官方推薦的就是上面這些,如果在編譯過程中發現某些命令找不到,就apt-get它。可能需要的包還有:

$ sudo apt-get install make
$ sudo apt-get install gcc
$ sudo apt-get install g++
$ sudo apt-get install libc6-dev

$ sudo apt-get install patch
$ sudo apt-get install texinfo

$ sudo apt-get install zlib1g-dev
$ sudo apt-get install valgrind
$ sudo apt-get install python2.5(或者更高版本)

需要注意的是,官方文檔說如果用sun-java6-jdk可出問題,得要用sun-java5- jdk。經測試發現,如果僅僅make(make不包括make sdk),用sun-java6-jdk是沒有問題的。而make sdk,就會有問題,嚴格來說是在make doc出問題,它需要的javadoc版本為1.5。

因此,我們安裝完sun-java6-jdk後最好再安裝sun-java5-jdk,或者只安裝sun-java5-jdk。這里sun-java6-jdk和sun-java5-jdk都安裝,並只修改javadoc.1.gz和javadoc。因為只有這兩個是make sdk用到的。這樣的話,除了javadoc工具是用1.5版本,其它均用1.6版本:

$ sudo apt-get install sun-java6-jdk

修改javadoc的link:

$ cd /etc/alternatives
$ sudo rm javadoc.1.gz
$ sudo ln -s /usr/lib/jvm/java-1.5.0-sun/man/man1/javadoc.1.gz javadoc.1.gz
$ sudo rm javadoc
$ sudo ln -s /usr/lib/jvm/java-1.5.0-sun/bin/javadoc javadoc

2)設置環境變數

$ emacs ~/.bashrc

在.bashrc中新增或整合PATH變數,如下:

#java 程序開發/運行的一些環境變數

JAVA_HOME=/usr/lib/jvm/java-6-sun
JRE_HOME=${JAVA_HOME}/jre
export ANDROID_JAVA_HOME=$JAVA_HOME
export CLASSPATH=.:${JAVA_HOME}/lib:$JRE_HOME/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export JAVA_HOME;
export JRE_HOME;
export CLASSPATH;
HOME_BIN=~/bin/
export PATH=${PATH}:${JAVA_PATH}:${HOME_BIN};

保存後,同步更新:

source ~/.bashrc

3)安裝repo(用來更新android源碼)

創建~/bin目錄,用來存放repo程序,如下:

$ cd ~
$ mkdir bin

並加到環境變數PATH中,在第2步中已經加入。

下載repo腳本並使其可執行:

$ curlhttp://android.git.kernel.org/repo>~/bin/repo
$ chmod a+x ~/bin/repo

4)初始化repo

repo是android對git的一個封裝,簡化了一些git的操作。

創建工程目錄:

$ mkdir android
$ cd android

repo初始化:

$ repo init -u git://android.git.kernel.org/platform/manifest.git

在此過程中需要輸入名字和email地址。初始化成功後,會顯示:

repo initialized in /android

在~/android下會有一個.repo的隱藏目錄。

5)同步源代碼

$ repo sync

這一步要很久很久。

6)編譯android源碼,並得到~/android/out目錄

$ cd ~/andoird
$ make

這一過程很久。

7)在模擬器上運行編譯好的android

編譯好android之後,emulator在~/android/out/host/linux-x86/bin下,ramdisk.img,system.img和userdata.img則在~/android/out/target/proct/generic下。

$ cd ~/android/out/host/linux-x86/bin

增加環境變數

$ emacs ~/.bashrc

在.bashrc中新增環境變數,如下

#java 程序開發/運行的一些環境變數

export ANDROID_PRODUCT_OUT=~/android/out/target/proct/generic
ANDROID_PRODUCT_OUT_BIN=~/android/out/host/linux-x86/bin
export PATH=${PATH}:${ANDROID_PRODUCT_OUT_BIN}:${ANDROID_PRODUCT_OUT};

最後,同步這些變化:

$ source ~/.bashrc
$ cd ~/android/out/target/proct/generic
$ emulator -system system.img -data userdata.img -ramdisk ramdisk.img

最後進入android桌面,就說明成功了。

8)編譯模塊

android中的一個應用程序可以單獨編譯,編譯後要重新生成system.img。

在源碼目錄下執行

$ . build/envsetup.sh (.後面有空格)

就多出一些命令:

- croot: Changes directory to the top of the tree.
- m: Makes from the top of the tree.
- mm: Builds all of the moles in the current directory.
- mmm: Builds all of the moles in the supplied directories.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
- godir: Go to the directory containing a file.

可以加—help查看用法。

我們可以使用mmm來編譯指定目錄的模塊,如編譯聯系人:

$ mmm packages/apps/Contacts/

編完之後生成兩個文件:

out/target/proct/generic/data/app/ContactsTests.apk
out/target/proct/generic/system/app/Contacts.apk

可以使用

$ make snod

重新生成system.img,再運行模擬器。

9)編譯SDK

直接執行make是不包括make sdk的。make sdk用來生成SDK,這樣,我們就可以用與源碼同步的SDK來開發android了。

a)修改/frameworks/base/include/utils/Asset.h

『UNCOMPRESS_DATA_MAX = 1 * 1024 * 1024』 改為 『UNCOMPRESS_DATA_MAX = 2 * 1024 * 1024』

原因是eclipse編譯工程需要大於1.3M的buffer;

b)編譯ADT

由於本人不使用eclipse,所以沒有進行這步;

c)執行make sdk

注意,這里需要的javadoc版本為1.5,所以你需要在步驟1中同時安裝sun-java5-jdk

$ make sdk

編譯很慢。編譯後生成的SDK存放在out/host/linux-x86/sdk/,此目錄下有android-sdk_eng.xxx_linux- x86.zip和android-sdk_eng.xxx_linux-x86目錄。android-sdk_eng.xxx_linux-x86就是 SDK目錄。

實際上,當用mmm命令編譯模塊時,一樣會把SDK的輸出文件清除,因此,最好把android-sdk_eng.xxx_linux-x86移出來。

此後的應用開發,就在該SDK上進行,所以把7)對於~/.bashrc的修改注釋掉,增加如下一行:

export PATH=${PATH}:~/android/out/host/linux-x86/sdk/android-sdk_eng.xxx_linux-x86/tools

注意要把xxx換成真實的路徑;

d)關於環境變數、android工具的選擇

目前的android工具有:

A、我們從網上下載的Android SDK,如果你下載過的話( tools下有許多android工具,lib/images下有img映像)
B、我們用make sdk編譯出來的SDK( tools下也有許多android工具,lib/images下有img映像)
C、我們用make編譯出來的out目錄( tools下也有許多android工具,lib/images下有img映像)

那麼我們應該用那些工具和img呢?

首先,我們一般不會用A選項的工具和img,因為一般來說它比較舊,也源碼不同步。其次,也不會用C選項的工具和img,因為這些工具和img沒有經過SDK的歸類處理,會有工具和配置找不到的情況;事實上,make sdk產生的很多工具和img,在make編譯出來out目錄的時候,已經編譯產生了,make sdk只是做了而已。

e)安裝、配置ADT
略過;

f)創建Android Virtual Device

編譯出來的SDK是沒有AVD(Android Virtual Device)的,我們可以通過android工具查看:

$ android list

創建AVD:

$ android create avd -t 1 -n myavd

可以android –help來查看上面命令選項的用法。創建中有一些選項,默認就行了。

再執行android list,可以看到AVD存放的位置。

以後每次運行emulator都要加-avd myavd或@myavd選項:

$ emulator -avd myavd

10)編譯linux內核映像

a)准備交叉編譯工具鏈

android代碼樹中有一個prebuilt項目,包含了我們編譯內核所需的交叉編譯工具。

b)設定環境變數

$ emacs ~/.bashrc

增加如下兩行:

export PATH=$PATH:~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin
export ARCH=arm

保存後,同步變化:

$ source ~/.bashrc

c)獲得合適的內核源代碼

$ cd ~/android

獲得內核源代碼倉庫

$ git clone git://android.git.kernel.org/kernel/common.git kernel
$ cd kernel
$ git branch

顯示

* android-2.6.27

說明你現在在android-2.6.27這個分支上,也是kernel/common.git的默認主分支。

顯示所有head分支:

$ git branch -a

顯示

* android-2.6.27
remotes/origin/HEAD -> origin/android-2.6.27
remotes/origin/android-2.6.25
remotes/origin/android-2.6.27
remotes/origin/android-2.6.29
remotes/origin/android-goldfish-2.6.27
remotes/origin/android-goldfish-2.6.29

我們選取最新的android-goldfish-2.6.29,其中goldfish是android的模擬器模擬的CPU。

$ git checkout -b android-goldfish-2.6.29 origin/android-goldfish-2.6.29
$ git branch

顯示

android-2.6.27
* android-goldfish-2.6.29

我們已經工作在android-goldfish-2.6.29分支上了。

d)設定交叉編譯參數

打開kernel目錄下的Makefile文件,把CROSS_COMPILE指向剛才下載的prebuilt中的arm-eabi編譯器.

CROSS_COMPILE ?= arm-eabi-

LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,
$(call ld-option, -Wl$(comma)–build-id,))

這一行注釋掉,並且添加一個空的LDFLAGS_BUILD_ID定義,如下:

LDFLAGS_BUILD_ID =

e)編譯內核映像

$ cd ~/android/kernel
$ make goldfish_defconfig
$ make

f)測試生成的內核映像

$ emulator -avd myavd -kernel ~/android/kernel/arch/arm/boot/zImage

6. 新人求教 驅動源碼編譯安裝

1、安裝scons
(1) 下載python2.7, 使用x86_32位,因為scons只有32位安裝包可用;
(2) 下載scons2.3.0;
(3) 安裝python 和 scons, 將C:\Python27\Scripts寫入PATH;
(4) 下載安裝pywin32 ,It is recommended you install pywin32 if you want to do parallel builds (scons -j)

2、安裝boost庫(1.49版本).
解壓後雙擊bootstrap.bat,生成bjam.exe後,cd到目錄c:\boost下,(將boost_1_49更名為boost了)編譯boost。
編譯命令:C:\boost>bjam variant=release --with-filesystem --with-thread --with-date_time --with-program_options threading=multi toolset=msvc-10.0 link=static runtime-link=static address-model=32
這是使用VS2010環境編譯的release版本,編譯完成後,生成C:\boost\stage\lib文件夾,下面有6個lib庫:

如果要編譯成debug版本,使用命令:bjam variant=debug --with-filesystem --with-thread --with-date_time --with-program_options threading=multi toolset=msvc-10.0 link=static runtime-link=static address-model=32

編譯完成後,生成C:\boost\stage\lib文件夾,下面有10個lib庫和dll:

此處為MongoDB文檔中對於編譯boost庫的要求原文:
When using bjam, MongoDB expects
variant=debug for debug builds, and variant=release for release builds
threading=multi
link=static runtime-link=static for release builds
address-model=64 for 64 bit(64位的話,把32換為64)。link=static runtime-link=static,boost需要編譯成靜態庫,因為mongodb只會去鏈接boost的靜態庫
address-model=64在win7 64環境下此項必須,不加在編譯mongodb的c++ client時會出現鏈接錯誤。

3、下載mongo2.4.6源碼 http://www.mongodb.org/downloads官網下載
編譯Mongoclient.lib

cmd命令提示符下,cd到解壓後的文件目錄,例如我放在了E盤,E:\mongodb-src-r2.4.6,輸入命令:
scons –-dd --32 mongoclient.lib // build C++ client driver library
Add --64 or --32 to get the 64- and 32-bit versions, respectively. Replace --release with --dd to build a debug build.
編譯後在mongodb\build\win32\32\dd\client_build\生成mongoclient.lib.

4、測試程序
就用Mongodb自帶的例子吧,使用VS2010打開E:\mongodb-src-r2.4.6\src\mongo\client\examples中的simple_client_demo.vcxproj,編譯,會提示生成simple_client_demo.sln,保存。
使用debug模式,配置工程環境:打開工程->屬性,配置Configuration Properties下的VC++ Directories,頭文件路徑添加C:\boost,Lib庫路徑添加boost的lib,以及mongodb client的lib:
C:\boost\stage\lib

E:\mongodb-src-r2.4.6\build\win32\32\dd\client_build
進入C/C++下面的Code Generation,將Runtime Library設置為Multi-threaded Debug (/MTd)
進入Linker下面的Input,設置Additional Dependencies,添加ws2_32.lib,psapi.lib,Dbghelp.lib,mongoclient.lib
將E:\mongodb-src-r2.4.6\build\win32\32\dd\mongo\base下生成的error_codes.h和error_codes.cpp文件,拷貝到E:\mongodb-src-r2.4.6\src\mongo\base目錄下。
ok,編譯、運行.

5、問題解決
error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in error_codes.obj
1>mongoclient_d.lib(dbclient.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in error_codes.obj
1>mongoclient_d.lib(assert_util.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in error_codes.obj
1>mongoclient_d.lib(jsobj.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in error_codes.obj
1>mongoclient_d.lib(status.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in error_codes.obj
1>mongoclient_d.lib(mutexdebugger.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1700' doesn't match value '1600' in error_codes.obj

VS的版本不匹配,lib是在更高級的版本中編譯生成的,而使用的時候,是在低級版本中使用的,所以出現了不匹配的錯誤。例如,我在VS2010 SP1和VS2012的環境下編譯的,而使用是在VS2010上使用,所以在編譯時,出現了以上問題。

1>mongoclient.lib(stacktrace.obj) : error LNK2001: unresolved external symbol __imp_SymCleanup
1>mongoclient.lib(stacktrace.obj) : error LNK2001: unresolved external symbol __imp_SymGetMoleInfo64
1>mongoclient.lib(stacktrace.obj) : error LNK2001: unresolved external symbol __imp_SymInitialize
1>mongoclient.lib(stacktrace.obj) : error LNK2001: unresolved external symbol __imp_StackWalk64
1>mongoclient.lib(stacktrace.obj) : error LNK2001: unresolved external symbol __imp_SymFromAddr

在工程依賴庫中添加Dbghelp.lib

其它問題,看看你手頭的編譯器、編譯出來的boost庫版本、mongoclient.lib的版本,是否對應好了。

7. GitHub 上有哪些完整的 iOS-App 源碼值得參考

1. Coding iOS 客戶端

Coding官方客戶端. 筆者強烈推薦的值得學習的完整APP.
GitHub - Coding/Coding-iOS: Coding iOS 客戶端源代碼
2. OSCHINA 的 iPhone 客戶端
開源中國的iPhone客戶端源碼
https://git.oschina.net/oschina/iphone-app
3. Git@OSC
Git@OSC iPhone 客戶端,方便用戶查看Git@OSC的項目以及簡單的操作issue等
oschina / git-osc-iphone
4. Firefox for iOS
GitHub - mozilla/firefox-ios: Firefox for iOS
5. zulip-ios
Dropbox收購公司內部社交服務商Zulip,然後全部開源,這是iOS App
GitHub - zulip/zulip-ios: Zulip iOS app
6. iOSSF
SegmentFault官方App
GitHub - gaosboy/iOSSF: SegmentFault官方App
7. iReddit
Reddit iPhone客戶端
GitHub - reddit/iReddit: The iReddit iPhone app
8. Monkey
GitHub第三方iOS客戶端
GitHub - coderyi/Monkey: Monkey is a GitHub third party client for iOS,to show the rank of coders and repositories.
9. Watch
Dribbble第三方客戶端
GitHub - tuesda/Watch: A project which demonstrate how to develop a custom client on android for dribbble.com
10. Voice2Note
懶人筆記iOS客戶端
GitHub - liaojinxing/Voice2Note: 懶人筆記iOS客戶端
11. RSSRead
「已閱」(iOS上開源RSS新聞閱讀器)
GitHub - ming1016/RSSRead: 「已閱」(iOS上開源RSS新聞閱讀器),有興趣?那就Pull Requests吧
12. BeeFancy
BeeFancy仿Fancy官方APP的WIREFRAME,基於BeeFramework
GitHub - BeeFramework/BeeFancy: 仿Fancy官方APP的WIREFRAME,基於BeeFramework
13. SXNews
模仿網易新聞做的精仿網易新聞
GitHub - dsxNiubility/SXNews: High imitation Neteasy News. (include list,detail,photoset,weather,feedback)
14. Doppio
尋找最近的星巴克
GitHub - chroman/Doppio: An open source iOS app to find the nearest Starbucks store using NSURLSession, AFNetworking 2.0, Mantle and Starbucks private API.
15. Anypic
類似於Instagram的一款App
GitHub - ParsePlatform/Anypic: An open source mobile and web app that lets users share photos similar to Instagram
16. 豆瓣相冊
Slowslab iOS應用 豆瓣相冊 精選集 開源項目
GitHub - TonnyTao/DoubanAlbum: Slowslab iOS應用 豆瓣相冊 精選集 開源項目,僅供學習參考
17. ChatSecure-iOS
Objective-C寫的XMPP聊天應用
GitHub - ChatSecure/ChatSecure-iOS: ChatSecure is a free and open source encrypted chat client for iPhone and Android that supports OTR encryption over XMPP.
18. NotificationChat
Objective-C寫的完整的聊天應用
GitHub - relatedcode/EncryptedChat: This is a full native iPhone app to create realtime, text based group or private chat with Parse and Firebase.
19. FakeZhihuDaily
仿知乎日報iOS客戶端
GitHub - gnou/FakeZhihuDaily: 仿知乎日報iOS客戶端
20. ruby-china-for-ios
RubyChina官方客戶端
GitHub - ruby-china/ruby-china-for-ios: Ruby China client for iOS
21. Meizi
豆瓣妹子圖iOS客戶端
GitHub - Sunnyyoung/Meizi: 豆瓣妹子圖iOS客戶端
22. PlainReader
一款 iOS(iPhone + iPad) 新聞類客戶端,內容抓取自http://cnBeta.com
PlainReader/PlainReader at master · guojiubo/PlainReader · GitHub
23. iOS-2048
用Objective-C實現的2048游戲
GitHub - austinzheng/iOS-2048: iOS drop-in library presenting a 2048-style game
24. ECMobile_iOS
基於ECShop的手機商城客戶端
GitHub - GeekZooStudio/ECMobile_iOS: 基於ECShop的手機商城客戶端
25. wikipedia-ios
維基網路官方App, 已上架
GitHub - wikimedia/wikipedia-ios: The official Wikipedia iOS app.
26. Sol
漂亮的扁平風格的天氣App
GitHub - comyarzaheri/Sol: Sol° beautifully displays weather information so you can plan your day accordingly. Check the weather in your current location or any city around the world. Implemented in Objective-C.

8. 如何查看Android SDK源碼版本

一種辦法是自帶SDK管理工具更新:

另外的辦法就是:
第一步:查看當前工程的SDK版本;

2.打開工程,查找任意一個函數,點擊右鍵,選擇查看源碼.

3.提示找不到java源文件,這里需要手動添加源文件;

4.按圖選擇.這里還沒有source的文件夾..所以..去下載相關平台的SDK的java源碼;

5.打開網址:http //rgruet free fr/public/
根據SDK版本下載對應的源碼,比如2.1的.

6.在SDK平台目錄下,新建一個sources文件夾;

7.把源碼直接解壓到當前文件夾下;

8.再次選擇查到源碼,並選擇sources文件夾;

9.eclipse會自動導入;

10.再次查看函數的源碼,是不是代碼就出來了.

9. 初級C語言源代碼

好的哦
#define N 200
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
int i,key;
int score=0;/*得分*/
int gamespeed=50000;/*游戲速度自己調整*/
struct Food
{
int x;/*食物的橫坐標*/
int y;/*食物的縱坐標*/
int yes;/*判斷是否要出現食物的變數*/
}food;/*食物的結構體*/
struct Snake
{
int x[N];
int y[N];
int node;/*蛇的節數*/
int direction;/*蛇移動方向*/
int life;/* 蛇的生命,0活著,1死亡*/
}snake;
void Init(void);/*圖形驅動*/
void Close(void);/*圖形結束*/
void DrawK(void);/*開始畫面*/
void GameOver(void);/*結束游戲*/
void GamePlay(void);/*玩游戲具體過程*/
void PrScore(void);/*輸出成績*/
/*主函數*/
void main(void)
{
Init();/*圖形驅動*/
DrawK();/*開始畫面*/
GamePlay();/*玩游戲具體過程*/
Close();/*圖形結束*/
}
/*圖形驅動*/
void Init(void)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
cleardevice();
}
/*開始畫面,左上角坐標為(50,40),右下角坐標為(610,460)的圍牆*/
void DrawK(void)
{
/*setbkcolor(LIGHTGREEN);*/
setcolor(11);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);/*設置線型*/
for(i=50;i<=600;i+=10)/*畫圍牆*/
{
rectangle(i,40,i+10,49); /*上邊*/
rectangle(i,451,i+10,460);/*下邊*/
}
for(i=40;i<=450;i+=10)
{
rectangle(50,i,59,i+10); /*左邊*/
rectangle(601,i,610,i+10);/*右邊*/
}
}
/*玩游戲具體過程*/
void GamePlay(void)
{
randomize();/*隨機數發生器*/
food.yes=1;/*1表示需要出現新食物,0表示已經存在食物*/
snake.life=0;/*活著*/
snake.direction=1;/*方嚮往右*/
snake.x[0]=100;snake.y[0]=100;/*蛇頭*/
snake.x[1]=110;snake.y[1]=100;
snake.node=2;/*節數*/
PrScore();/*輸出得分*/
while(1)/*可以重復玩游戲,壓ESC鍵結束*/
{
while(!kbhit())/*在沒有按鍵的情況下,蛇自己移動身體*/
{
if(food.yes==1)/*需要出現新食物*/
{
food.x=rand()%400+60;
food.y=rand()%350+60;
while(food.x%10!=0)/*食物隨機出現後必須讓食物能夠在整格內,這樣才可以讓蛇吃到*/
food.x++;
while(food.y%10!=0)
food.y++;
food.yes=0;/*畫面上有食物了*/
}
if(food.yes==0)/*畫面上有食物了就要顯示*/
{
setcolor(GREEN);
rectangle(food.x,food.y,food.x+10,food.y-10);
}
for(i=snake.node-1;i>0;i--)/*蛇的每個環節往前移動,也就是貪吃蛇的關鍵演算法*/
{
snake.x[i]=snake.x[i-1];
snake.y[i]=snake.y[i-1];
}
/*1,2,3,4表示右,左,上,下四個方向,通過這個判斷來移動蛇頭*/
switch(snake.direction)
{
case 1:snake.x[0]+=10;break;
case 2: snake.x[0]-=10;break;
case 3: snake.y[0]-=10;break;
case 4: snake.y[0]+=10;break;
}
for(i=3;i<snake.node;i++)/*從蛇的第四節開始判斷是否撞到自己了,因為蛇頭為兩節,第三節不可能拐過來*/
{
if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])
{
GameOver();/*顯示失敗*/
snake.life=1;
break;
}
}
if(snake.x[0]<55||snake.x[0]>595||snake.y[0]<55||
snake.y[0]>455)/*蛇是否撞到牆壁*/
{
GameOver();/*本次游戲結束*/
snake.life=1; /*蛇死*/
}
if(snake.life==1)/*以上兩種判斷以後,如果蛇死就跳出內循環,重新開始*/
break;
if(snake.x[0]==food.x&&snake.y[0]==food.y)/*吃到食物以後*/
{
setcolor(0);/*把畫面上的食物東西去掉*/
rectangle(food.x,food.y,food.x+10,food.y-10);
snake.x[snake.node]=-20;snake.y[snake.node]=-20;
/*新的一節先放在看不見的位置,下次循環就取前一節的位置*/
snake.node++;/*蛇的身體長一節*/
food.yes=1;/*畫面上需要出現新的食物*/
score+=10;
PrScore();/*輸出新得分*/
}
setcolor(4);/*畫出蛇*/
for(i=0;i<snake.node;i++)
rectangle(snake.x[i],snake.y[i],snake.x[i]+10,
snake.y[i]-10);
delay(gamespeed);
setcolor(0);/*用黑色去除蛇的的最後一節*/
rectangle(snake.x[snake.node-1],snake.y[snake.node-1],
snake.x[snake.node-1]+10,snake.y[snake.node-1]-10);
} /*endwhile(!kbhit)*/
if(snake.life==1)/*如果蛇死就跳出循環*/
break;
key=bioskey(0);/*接收按鍵*/
if(key==ESC)/*按ESC鍵退出*/
break;
else
if(key==UP&&snake.direction!=4)
/*判斷是否往相反的方向移動*/
snake.direction=3;
else
if(key==RIGHT&&snake.direction!=2)
snake.direction=1;
else
if(key==LEFT&&snake.direction!=1)
snake.direction=2;
else
if(key==DOWN&&snake.direction!=3)
snake.direction=4;
}/*endwhile(1)*/
}
/*游戲結束*/
void GameOver(void)
{
cleardevice();
PrScore();
setcolor(RED);
settextstyle(0,0,4);
outtextxy(200,200,"GAME OVER");
getch();
}
/*輸出成績*/
void PrScore(void)
{
char str[10];
setfillstyle(SOLID_FILL,YELLOW);
bar(50,15,220,35);
setcolor(6);
settextstyle(0,0,2);
sprintf(str,"score:%d",score);
outtextxy(55,20,str);
}
/*圖形結束*/
void Close(void)
{
getch();
closegraph();
}
#include <dos.h> /*DOS介面函數*/
#include <math.h> /*數學函數的定義*/
#include <conio.h> /*屏幕操作函數*/
#include <stdio.h> /*I/O函數*/
#include <stdlib.h> /*庫函數*/
#include <stdarg.h> /*變數長度參數表*/
#include <graphics.h> /*圖形函數*/
#include <string.h> /*字元串函數*/
#include <ctype.h> /*字元操作函數*/
#define UP 0x48 /*游標上移鍵*/
#define DOWN 0x50 /*游標下移鍵*/
#define LEFT 0x4b /*游標左移鍵*/
#define RIGHT 0x4d /*游標右移鍵*/
#define ENTER 0x0d /*回車鍵*/
void *rar; /*全局變數,保存游標圖象*/
struct palettetype palette; /*使用調色板信息*/
int GraphDriver; /* 圖形設備驅動*/
int GraphMode; /* 圖形模式值*/
int ErrorCode; /* 錯誤代碼*/
int MaxColors; /* 可用顏色的最大數值*/
int MaxX, MaxY; /* 屏幕的最大解析度*/
double AspectRatio; /* 屏幕的像素比*/
void drawboder(void); /*畫邊框函數*/
void initialize(void); /*初始化函數*/
void computer(void); /*計算器計算函數*/
void changetextstyle(int font, int direction, int charsize); /*改變文本樣式函數*/
void mwindow(char *header); /*窗口函數*/
int specialkey(void) ; /*獲取特殊鍵函數*/
int arrow(); /*設置箭頭游標函數*/
/*主函數*/
int main()
{
initialize();/* 設置系統進入圖形模式 */
computer(); /*運行計算器 */
closegraph();/*系統關閉圖形模式返迴文本模式*/
return(0); /*結束程序*/
}
/* 設置系統進入圖形模式 */
void initialize(void)
{
int xasp, yasp; /* 用於讀x和y方向縱橫比*/
GraphDriver = DETECT; /* 自動檢測顯示器*/
initgraph( &GraphDriver, &GraphMode, "" );
/*初始化圖形系統*/
ErrorCode = graphresult(); /*讀初始化結果*/
if( ErrorCode != grOk ) /*如果初始化時出現錯誤*/
{
printf("Graphics System Error: %s\n",
grapherrormsg( ErrorCode ) ); /*顯示錯誤代碼*/
exit( 1 ); /*退出*/
}
getpalette( &palette ); /* 讀面板信息*/
MaxColors = getmaxcolor() + 1; /* 讀取顏色的最大值*/
MaxX = getmaxx(); /* 讀屏幕尺寸 */
MaxY = getmaxy(); /* 讀屏幕尺寸 */
getaspectratio( &xasp, &yasp ); /* 拷貝縱橫比到變數中*/
AspectRatio = (double)xasp/(double)yasp;/* 計算縱橫比值*/
}
/*計算器函數*/
void computer(void)
{
struct viewporttype vp; /*定義視口類型變數*/
int color, height, width;
int x, y,x0,y0, i, j,v,m,n,act,flag=1;
float num1=0,num2=0,result; /*操作數和計算結果變數*/
char cnum[5],str2[20]={""},c,temp[20]={""};
char str1[]="1230.456+-789*/Qc=^%";/* 定義字元串在按鈕圖形上顯示的符號 */
mwindow( "Calculator" ); /* 顯示主窗口 */
color = 7; /*設置灰顏色值*/
getviewsettings( &vp ); /* 讀取當前窗口的大小*/
width=(vp.right+1)/10; /* 設置按鈕寬度 */
height=(vp.bottom-10)/10 ; /*設置按鈕高度 */
x = width /2; /*設置x的坐標值*/
y = height/2; /*設置y的坐標值*/
setfillstyle(SOLID_FILL, color+3);
bar( x+width*2, y, x+7*width, y+height );
/*畫一個二維矩形條顯示運算數和結果*/
setcolor( color+3 ); /*設置淡綠顏色邊框線*/
rectangle( x+width*2, y, x+7*width, y+height );
/*畫一個矩形邊框線*/
setcolor(RED); /*設置顏色為紅色*/
outtextxy(x+3*width,y+height/2,"0."); /*輸出字元串"0."*/
x =2*width-width/2; /*設置x的坐標值*/
y =2*height+height/2; /*設置y的坐標值*/
for( j=0 ; j<4 ; ++j ) /*畫按鈕*/
{
for( i=0 ; i<5 ; ++i )
{
setfillstyle(SOLID_FILL, color);
setcolor(RED);
bar( x, y, x+width, y+height ); /*畫一個矩形條*/
rectangle( x, y, x+width, y+height );
sprintf(str2,"%c",str1[j*5+i]);
/*將字元保存到str2中*/
outtextxy( x+(width/2), y+height/2, str2);
x =x+width+ (width / 2) ; /*移動列坐標*/
}
y +=(height/2)*3; /* 移動行坐標*/
x =2*width-width/2; /*復位列坐標*/
}
x0=2*width;
y0=3*height;
x=x0;
y=y0;
gotoxy(x,y); /*移動游標到x,y位置*/
arrow(); /*顯示游標*/
putimage(x,y,rar,XOR_PUT);
m=0;
n=0;
strcpy(str2,""); /*設置str2為空串*/
while((v=specialkey())!=45) /*當壓下Alt+x鍵結束程序,否則執行下面的循環*/
{
while((v=specialkey())!=ENTER) /*當壓下鍵不是回車時*/
{
putimage(x,y,rar,XOR_PUT); /*顯示游標圖象*/
if(v==RIGHT) /*右移箭頭時新位置計算*/
if(x>=x0+6*width)
/*如果右移,移到尾,則移動到最左邊字元位置*/
{
x=x0;
m=0;
}
else
{
x=x+width+width/2;
m++;
} /*否則,右移到下一個字元位置*/
if(v==LEFT) /*左移箭頭時新位置計算*/
if(x<=x0)
{
x=x0+6*width;
m=4;
} /*如果移到頭,再左移,則移動到最右邊字元位置*/
else
{
x=x-width-width/2;
m--;
} /*否則,左移到前一個字元位置*/
if(v==UP) /*上移箭頭時新位置計算*/
if(y<=y0)
{
y=y0+4*height+height/2;
n=3;
} /*如果移到頭,再上移,則移動到最下邊字元位置*/
else
{
y=y-height-height/2;
n--;
} /*否則,移到上邊一個字元位置*/
if(v==DOWN) /*下移箭頭時新位置計算*/
if(y>=7*height)
{
y=y0;
n=0;
} /*如果移到尾,再下移,則移動到最上邊字元位置*/
else
{
y=y+height+height/2;
n++;
} /*否則,移到下邊一個字元位置*/
putimage(x,y,rar,XOR_PUT); /*在新的位置顯示游標箭頭*/
}
c=str1[n*5+m]; /*將字元保存到變數c中*/
if(isdigit(c)||c=='.') /*判斷是否是數字或小數點*/
{
if(flag==-1) /*如果標志為-1,表明為負數*/
{
strcpy(str2,"-"); /*將負號連接到字元串中*/
flag=1;
} /*將標志值恢復為1*/
sprintf(temp,"%c",c); /*將字元保存到字元串變數temp中*/
strcat(str2,temp); /*將temp中的字元串連接到str2中*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,str2); /*顯示字元串*/
}
if(c=='+')
{
num1=atof(str2); /*將第一個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=1; /*做計算加法標志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='-')
{
if(strcmp(str2,"")==0) /*如果str2為空,說明是負號,而不是減號*/
flag=-1; /*設置負數標志*/
else
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=2; /*做計算減法標志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
}
if(c=='*')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=3; /*做計算乘法標志值*/
setfillstyle(SOLID_FILL,color+3); bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='/')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=4; /*做計算除法標志值*/
setfillstyle(SOLID_FILL,color+3);
bar(2*width+width/2,height/2,15*width/2,3*height/2);
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='^')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=5; /*做計算乘方標志值*/
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='%')
{
num1=atof(str2); /*將第二個操作數轉換為浮點數*/
strcpy(str2,""); /*將str2清空*/
act=6; /*做計算模運算乘方標志值*/
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*畫矩形*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='=')
{
num2=atof(str2); /*將第二個操作數轉換為浮點數*/
switch(act) /*根據運算符號計算*/
{
case 1:result=num1+num2;break; /*做加法*/
case 2:result=num1-num2;break; /*做減法*/
case 3:result=num1*num2;break; /*做乘法*/
case 4:result=num1/num2;break; /*做除法*/
case 5:result=pow(num1,num2);break; /*做x的y次方*/
case 6:result=fmod(num1,num2);break; /*做模運算*/
}
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆蓋結果區*/
sprintf(temp,"%f",result); /*將結果保存到temp中*/
outtextxy(5*width,height,temp); /*顯示結果*/
}
if(c=='c')
{
num1=0; /*將兩個操作數復位0,符號標志為1*/
num2=0;
flag=1;
strcpy(str2,""); /*將str2清空*/
setfillstyle(SOLID_FILL,color+3); /*設置用淡綠色實體填充*/
bar(2*width+width/2,height/2,15*width/2,3*height/2); /*覆蓋結果區*/
outtextxy(5*width,height,"0."); /*顯示字元串*/
}
if(c=='Q')exit(0); /*如果選擇了q回車,結束計算程序*/
}
putimage(x,y,rar,XOR_PUT); /*在退出之前消去游標箭頭*/
return; /*返回*/
}
/*窗口函數*/
void mwindow( char *header )
{
int height;
cleardevice(); /* 清除圖形屏幕 */
setcolor( MaxColors - 1 ); /* 設置當前顏色為白色*/
setviewport( 20, 20, MaxX/2, MaxY/2, 1 ); /* 設置視口大小 */
height = textheight( "H" ); /* 讀取基本文本大小 */
settextstyle( DEFAULT_FONT, HORIZ_DIR, 1 );/*設置文本樣式*/
settextjustify( CENTER_TEXT, TOP_TEXT );/*設置字元排列方式*/
outtextxy( MaxX/4, 2, header ); /*輸出標題*/
setviewport( 20,20+height+4, MaxX/2+4, MaxY/2+20, 1 ); /*設置視口大小*/
drawboder(); /*畫邊框*/
}
void drawboder(void) /*畫邊框*/
{
struct viewporttype vp; /*定義視口類型變數*/
setcolor( MaxColors - 1 ); /*設置當前顏色為白色 */
setlinestyle( SOLID_LINE, 0, NORM_WIDTH );/*設置畫線方式*/
getviewsettings( &vp );/*將當前視口信息裝入vp所指的結構中*/
rectangle( 0, 0, vp.right-vp.left, vp.bottom-vp.top ); /*畫矩形邊框*/
}
/*設計滑鼠圖形函數*/
int arrow()
{
int size;
int raw[]={4,4,4,8,6,8,14,16,16,16,8,6,8,4,4,4}; /*定義多邊形坐標*/
setfillstyle(SOLID_FILL,2); /*設置填充模式*/
fillpoly(8,raw); /*畫出一游標箭頭*/
size=imagesize(4,4,16,16); /*測試圖象大小*/
rar=malloc(size); /*分配內存區域*/
getimage(4,4,16,16,rar); /*存放游標箭頭圖象*/
putimage(4,4,rar,XOR_PUT); /*消去游標箭頭圖象*/
return 0;
}
/*按鍵函數*/
int specialkey(void)
{
int key;
while(bioskey(1)==0); /*等待鍵盤輸入*/
key=bioskey(0); /*鍵盤輸入*/
key=key&0xff? key&0xff:key>>8; /*只取特殊鍵的掃描值,其餘為0*/
return(key); /*返回鍵值*/
}
#include <dos.h> /*DOS介面函數*/
#include <math.h> /*數學函數的定義*/
#include <conio.h> /*屏幕操作函數*/
#include <stdio.h> /*I/O函數*/
#include <stdlib.h> /*庫函數*/
#include <stdarg.h> /*變數長度參數表*/
#include <graphics.h> /*圖形函數*/
#include <string.h> /*字元串函數*/
#include <ctype.h> /*字元操作函數*/
#define UP 0x48 /*游標上移鍵*/
#define DOWN 0x50 /*游標下移鍵*/
#define LEFT 0x4b /*游標左移鍵*/
#define RIGHT 0x4d /*游標右移鍵*/
#define ENTER 0x0d /*回車鍵*/
void *rar; /*全局變數,保存游標圖象*/
struct palettetype palette; /*使用調色板信息*/
int GraphDriver; /* 圖形設備驅動*/
int GraphMode; /* 圖形模式值*/
int ErrorCode; /* 錯誤代碼*/
int MaxColors; /* 可用顏色的最大數值*/
int MaxX, MaxY; /* 屏幕的最大解析度*/
double AspectRatio; /* 屏幕的像素比*/
void drawboder(void); /*畫邊框函數*/
void initialize(void); /*初始化函數*/
void computer(void); /*計算器計算函數*/
void changetextstyle(int font, int direction, int charsize); /*改變文本樣式函數*/
void mwindow(char *header); /*窗口函數*/
int specialkey(void) ; /*獲取特殊鍵函數*/
int arrow(); /*設置箭頭游標函數*/
/*主函數*/
int main()
{
initialize();/* 設置系統進入圖形模式 */
computer(); /*運行計算器 */
closegraph();/*系統關閉圖形模式返迴文本模式*/
return(0); /*結束程序*/
}
/* 設置系統進入圖形模式 */
void initialize(void)
{
int xasp, yasp; /* 用於讀x和y方向縱橫比*/
GraphDriver = DETECT; /* 自動檢測顯示器*/
initgraph( &GraphDriver, &GraphMode, "" );
/*初始化圖形系統*/
ErrorCode = graphresult(); /*讀初始化結果*/
if( ErrorCode != grOk ) /*如果初始化時出現錯誤*/
{
printf("Graphics System Error: %s\n",
grapherrormsg( ErrorCode ) ); /*顯示錯誤代碼*/
exit( 1 ); /*退出*/
}
getpalette( &palette ); /* 讀面板信息*/
MaxColors = getmaxcolor() + 1; /* 讀取顏色的最大值*/
MaxX = getmaxx(); /* 讀屏幕尺寸 */
MaxY = getmaxy(); /* 讀屏幕尺寸 */
getaspectratio( &xasp, &yasp ); /* 拷貝縱橫比到變數中*/
AspectRatio = (double)xasp/(double)yasp;/* 計算縱橫比值*/
}
/*計算器函數*/
void computer(void)
{
struct viewporttype vp; /*定義視口類型變數*/
int color, height, width;
int x, y,x0,y0, i, j,v,m,n,act,flag=1;
float num1=0,num2=0,result; /*操作數和計算結果變數*/
char cnum[5],str2[20]={""},c,temp[20]={""};
char str1[]="1230.456+-789*/Qc=^%";/* 定義字元串在按鈕圖形上顯示的符號 */
mwindow( "Calculator" ); /* 顯示主窗口 */
color = 7; /*設置灰顏色值*/
getviewsettings( &vp ); /* 讀取當前窗口的大小*/
width=(vp.right+1)/10; /* 設置按鈕寬度 */
height=(vp.bottom-10)/10 ; /*設置按鈕高度 */
x = width /2; /*設置x的坐標值*/
y = height/2; /*設置y的坐標值*/
setfillstyle(SOLID_FILL, color+3);
bar( x+width*2, y, x+7*width, y+height );
/*畫一個二維矩形條顯示運算數和結果*/
setcolor( color+3 ); /*設置淡綠顏色邊框線*/
rectangle( x+width*2, y, x+7*width, y+height );
/*畫一個矩形邊框線*/
setcolor(RED); /*設置顏色為紅色*/
outtextxy(x+3*width,y+height/2,"0."); /*輸出字元串"0."*/
x =2*width-width/2; /*設置x的坐標值*/
y =2*height+height/2; /*設置y的坐標值*/
for( j=0 ; j<4 ; ++j ) /*畫按鈕*/
{
for( i=0 ; i<5 ; ++i )
{
setfillstyle(SOLID_FILL, color);
setcolor(RED);
bar( x, y, x+width, y+height ); /*畫一個矩形條*/
rectangle( x, y, x+width, y+height );
sprintf(str2,"%c",str1[j*5+i]);
/*將字元保存到str2中*/
outtextxy( x+(width/2), y+height/2, str2);
x =x+width+ (width / 2) ; /*移動列坐標*/
}
y +=(height/2)*3; /* 移動行坐標*/
x =2*width-width/2; /*復位列坐標*/
}
x0=2*width;
y0=3*height;
x=x0;
y=y0;
gotoxy(x,y); /*移動游標到x,y位置*/
arrow(); /*顯示游標*/
putimage(x,y,rar,XOR_PUT);
m=0;
n=0;
strcpy(str2,""); /*設置str2為空串*/
while((v=specialkey())!=45) /*當壓下Alt+x鍵結束程序,否則執行下面的循環*/
{
while((v=specialkey())!=ENTER) /*當壓下鍵不是回車時*/
{
putimage(x,y,rar,XOR_PUT); /*顯示游標圖象*/
if(v==RIGHT) /*右

10. Java eclipse中無法查看源代碼

1.點 「window「-> 「Preferences」-> 「Java」 -> 「Installed JRES」;
2.此時"Installed JRES"右邊是列表窗格,列空首出了系統中的JRE 環境,選擇你的JRE,然後點邊上的「Edit...「, 會出現一個窗口(Edit JRE) ;
3.選中rt.jar文件的這一項:「C:\Java\jdk1.5.0_04\jre\lib\rt.jar」 點 左邊的「+」號展開它(JDK實際安裝路徑以你的為准);
4.展開後,可以看到「Source Attachment:(none)」,點這一項,點右邊的按拆沖鈕「Source Attachment...「,選擇你的JDK目錄旅虧殲下的 「src.zip」文件;
5.一路點「ok」結束。

熱點內容
廣州社保卡密碼激活在哪裡辦 發布:2024-04-19 17:21:18 瀏覽:367
編譯器和操作系統有關系嗎 發布:2024-04-19 17:20:28 瀏覽:273
數學公式編譯器下載 發布:2024-04-19 17:02:52 瀏覽:986
網頁無法緩存視頻 發布:2024-04-19 16:56:44 瀏覽:614
演算法紅 發布:2024-04-19 16:44:42 瀏覽:624
海量數據存儲與處理 發布:2024-04-19 16:33:46 瀏覽:541
微信聊天記錄怎麼恢復安卓手機 發布:2024-04-19 16:33:24 瀏覽:810
我的世界正版好玩的pvp伺服器 發布:2024-04-19 16:28:38 瀏覽:17
光遇安卓渠道服怎麼更換實名認證 發布:2024-04-19 16:18:08 瀏覽:263
關閉ip訪問 發布:2024-04-19 15:59:18 瀏覽:730