Title: compiler does not find the NetcdfFileWriter identifiers · Issue #29 · trung/InMemoryJavaCompiler · GitHub
Open Graph Title: compiler does not find the NetcdfFileWriter identifiers · Issue #29 · trung/InMemoryJavaCompiler
X Title: compiler does not find the NetcdfFileWriter identifiers · Issue #29 · trung/InMemoryJavaCompiler
Description: I would like to convert String variables to java code to build a NetCDF file from strings. I have some Strings which contain the commands to write a netCDF. For example: String Variable contains the following strings: 'Variable time; ' '...
Open Graph Description: I would like to convert String variables to java code to build a NetCDF file from strings. I have some Strings which contain the commands to write a netCDF. For example: String Variable contains th...
X Description: I would like to convert String variables to java code to build a NetCDF file from strings. I have some Strings which contain the commands to write a netCDF. For example: String Variable contains th...
Opengraph URL: https://github.com/trung/InMemoryJavaCompiler/issues/29
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":" compiler does not find the NetcdfFileWriter identifiers","articleBody":"I would like to convert String variables to java code to build a NetCDF file from strings. I have some Strings which contain the commands to write a netCDF. For example: \r\n\r\nString Variable contains the following strings: \r\n'Variable time; '\r\n'time = ncfile.addVariable(null, \"time\", DataType.Double, \"time\");'\r\n\r\nString DataA contains:\r\n'ArrayDouble.D1 timeData = new ArrayDouble.D1(countLinesResult); '\r\n'Index ima = timeData.getIndex();'\r\n\r\nString DataD contains:\r\n'timeData.setDouble(ima.set(timeIdx),ValueD.get(timeIdx)); ' \r\n\r\nString DataNC contains:\r\n'ncfile.write(time, timeData); '\r\n\r\neach string is public static String. These strings are in NetCDF_writer Class static void getDataNc method. Here is the code:\r\n```\r\npackage meteoread;\r\n\r\n/**\r\n *\r\n * @author Beata\r\n */\r\n;\r\nimport java.sql.Connection;\r\nimport java.sql.PreparedStatement;\r\nimport java.sql.ResultSet;\r\nimport java.sql.ResultSetMetaData;\r\nimport java.text.ParseException;\r\nimport java.text.SimpleDateFormat;\r\nimport java.util.ArrayList;\r\nimport java.util.Calendar;\r\nimport java.util.Date;\r\nimport java.util.GregorianCalendar;\r\nimport java.util.Iterator;\r\nimport static meteoread.DownLoad_Meteo.Detected;\r\nimport static meteoread.DownLoad_Meteo.ETime;\r\nimport static meteoread.DownLoad_Meteo.STime;\r\nimport static meteoread.DownLoad_Meteo.Values;\r\nimport static meteoread.DownLoad_Meteo.Values2;\r\nimport static meteoread.DownLoad_Meteo.id1;\r\nimport static meteoread.DownLoad_Meteo.id2;\r\nimport static meteoread.DownLoad_Meteo.listString;\r\nimport static meteoread.DownLoad_Meteo.res;\r\nimport static meteoread.SelectData.result;\r\nimport org.mdkt.compiler.InMemoryJavaCompiler;\r\n\r\nimport ucar.nc2.*;\r\n\r\nimport ucar.ma2.*;\r\n\r\npublic class NetCDF_writer {\r\n private static String okW =\"\";\r\n private static int is;\r\n private static int il;\r\n private static int di;\r\n private static int countLinesResult;\r\n public static String TableNC = DownLoad_Meteo.Table;\r\n private static ArrayList\u003cString\u003e s = new ArrayList\u003cString\u003e();\r\n private static ArrayList\u003cString\u003e s2 = new ArrayList\u003cString\u003e();\r\n private static ArrayList\u003cString\u003e s3 = new ArrayList\u003cString\u003e();\r\n private static ArrayList\u003cString\u003e s4 = new ArrayList\u003cString\u003e();\r\n private static ArrayList\u003cString\u003e s5 = new ArrayList\u003cString\u003e();\r\n private String[] colName;\r\n private static ArrayList\u003cString\u003e ValueS = new ArrayList\u003cString\u003e();\r\n private static ArrayList\u003cInteger\u003e ValueI = new ArrayList\u003cInteger\u003e();\r\n private static ArrayList\u003cDouble\u003e ValueD = new ArrayList\u003cDouble\u003e();\r\n public static String Variables;\r\n public static String DataA;\r\n public static String DataD;\r\n public static String DataNC;\r\n\r\n \r\n \r\n\r\n static void getDataNc(int id1, int id2, String listString, String location, String Stimenc, String ETimenc)throws Exception {\r\n \r\n \r\n try{\r\n Connection con = MeteoRead.getConnection();\r\n PreparedStatement statement= con.prepareStatement(\"SELECT \" + listString + \" FROM \" +TableNC + \" WHERE TIME_ID BETWEEN \" +\"\\\"\" + STime + \"\\\"\" +\" AND \" + \"\\\"\" +ETime + \"\\\"\" + \" ORDER BY ID\");\r\n\r\n ResultSet result = statement.executeQuery();\r\n ResultSetMetaData rsmd = result.getMetaData();\r\n \r\n\r\n is = id1; \r\n \r\n il = id2;\r\n \r\n di = il-is;\r\n \r\n if(is == 1){\r\n countLinesResult = il;\r\n }\r\n else{\r\n countLinesResult = di;}\r\n result.first();\r\n result.previous();\r\n \r\n \r\n ColName = listString.split(\",\");\r\n\r\n \r\n NetcdfFileWriter ncfile = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf4, location, null);\r\n Dimension timeDim = ncfile.addUnlimitedDimension(\"time\");\r\n \r\n \r\n s = SelectData.result.get(1);\r\n s2 = SelectData.result.get(2);\r\n s3 = SelectData.result.get(3);\r\n s4 = SelectData.result.get(4);\r\n s5 = SelectData.result.get(5);\r\n\r\n\r\n Variables = \"\";\r\n DataA = \"\";\r\n DataD = \"\";\r\n DataNC = \"\";\r\n int n = 0;\r\n \r\n while(n \u003c s.size()-1){\r\n \r\n Variables = Variables +\" \" + s.get(n) + \"\\n\";\r\n \r\n Variables = Variables +\" \" + s2.get(n) + \"\\n\";\r\n \r\n while(result.next()){\r\n \r\n Date date2 = dateConv1(result.getString(\"TIME\"));\r\n \r\n double dateU = ToMATLABDate(date2);\r\n \r\n if(rsmd.getColumnName(n+1).equals(\"TIME\")){\r\n \r\n ValueD.add(dateU);\r\n }\r\n \r\n if(rsmd.getColumnTypeName(n+1)== \"VARCHAR\" \u0026\u0026 !rsmd.getColumnName(n+1).equals(\"TIME\")){\r\n \r\n ValueS.add(result.getString(ColName[n]));\r\n }\r\n \r\n if(rsmd.getColumnTypeName(n+1)== \"INTEGER\"){\r\n \r\n ValueI.add(result.getInt(ColName[n]));\r\n }\r\n \r\n if(rsmd.getColumnTypeName(n+1)== \"DOUBLE\"){\r\n \r\n ValueD.add(result.getDouble(ColName[n]));\r\n }\r\n }\r\n \r\n DataA = DataA + s3.get(n) + \"\\n\";\r\n DataD = DataD + s4.get(n) + \"\\n\";\r\n DataNC = DataNC + s5.get(n) + \"\\n\";\r\n \r\n \r\n n++; }\r\n \r\n \r\n \r\n \r\n StringBuffer sourceCode = new StringBuffer();\r\n sourceCode.append(\"package meteoread;\\n\");\r\n sourceCode.append(\"public class NetCDF_writer {\\n\");\r\n sourceCode.append(\" static void getDataNc(int id1, int id2, String listString, String location, String Stimenc, String ETimenc)throws Exception {\" +Variables +\" ncfile.create();\" + \"\\n\" + DataA +\" for (int timeIdx = 0; timeIdx \u003c countLinesResult; timeIdx ++){\" + DataD + \"}\"+ DataNC + \"}\");\r\n sourceCode.append(\"}\"); \r\n Class\u003c?\u003e Netcdf_writer = InMemoryJavaCompiler.compile(\"meteoread.NetCDF_writer\", sourceCode.toString());\r\n \r\n okW = \"NC FILE BUILD SUCCESSFULLY\";\r\n okWindow o = new okWindow();\r\n o.okWindow(okW);\r\n o.setVisible(true);\r\n \r\n } catch(Exception e){\r\n e.printStackTrace();\r\n okW = e.toString();\r\n okWindow o = new okWindow();\r\n o.okWindow(okW);\r\n o.setVisible(true);}\r\n\r\n }\r\n \r\n \r\n public static Date dateConv1(String s){\r\n SimpleDateFormat formatter = new SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss\");\r\n String dateInString = s;\r\n Date date = new Date();\r\n \r\n \r\n try {\r\n\r\n date = (Date)formatter.parse(dateInString);\r\n } catch (ParseException e) {\r\n e.printStackTrace();\r\n }\r\n return date;\r\n }\r\n \r\n /**\r\n * Converts a java.util.Date into a MATLAB Serial Date Number in the local timezone. MATLAB Serial Date Number are\r\n * doubles counting the number of days since January 0 0000. The time of day is represented in fractions of a whole\r\n * day.\r\n *\r\n * @param date the date to convert\r\n * @return the date as MATLAB Serial Date Number\r\n */\r\n public static double ToMATLABDate(Date date) {\r\n // Converts a java.util.Date into a MATLAB Serial Date Number taking into account timezones and DST.\r\n Calendar cal = new GregorianCalendar();\r\n cal.setTime(date);\r\n double SerialDateNumber = (date.getTime() + cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 1000.0 / 3600.0 / 24.0 ;\r\n return SerialDateNumber;\r\n }\r\n\r\n \r\n}\r\n```\r\nUnfortunately, I got several cannot find symbol error messages. The compiler does not find the NetcdfFileWriter identifiers even though I imported ucar.nc2.* and ucar.ma2.* packages. Could you please write to me how I should fix this issue?","author":{"url":"https://github.com/szabotakacsb","@type":"Person","name":"szabotakacsb"},"datePublished":"2020-01-28T07:23:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/29/InMemoryJavaCompiler/issues/29"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9e496180-0d6d-224e-bdbc-0e31a371f0f8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 916C:1DC7:780985:96875E:697E7894 |
| html-safe-nonce | 02078c51eb7f66369e444dd3a6c11807581a2d619efe47df76402b8f1a8d93f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTZDOjFEQzc6NzgwOTg1Ojk2ODc1RTo2OTdFNzg5NCIsInZpc2l0b3JfaWQiOiI3NDAyNDIxOTc5NjU2MDA5MTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 787438e4b053b0661133aea42a8f2a105a5a669f3fc9dc8bfe700657981c12de |
| hovercard-subject-tag | issue:556029060 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/trung/InMemoryJavaCompiler/29/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2321dd0fc0fee7d8f8a849851899f64c8a7cb393f1e38b33bf6002f6c3a188b8/trung/InMemoryJavaCompiler/issues/29 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2321dd0fc0fee7d8f8a849851899f64c8a7cb393f1e38b33bf6002f6c3a188b8/trung/InMemoryJavaCompiler/issues/29 |
| og:image:alt | I would like to convert String variables to java code to build a NetCDF file from strings. I have some Strings which contain the commands to write a netCDF. For example: String Variable contains th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | szabotakacsb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/trung/InMemoryJavaCompiler git https://github.com/trung/InMemoryJavaCompiler.git |
| octolytics-dimension-user_id | 24930 |
| octolytics-dimension-user_login | trung |
| octolytics-dimension-repository_id | 31716516 |
| octolytics-dimension-repository_nwo | trung/InMemoryJavaCompiler |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31716516 |
| octolytics-dimension-repository_network_root_nwo | trung/InMemoryJavaCompiler |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width