Title: j2py not converting · Issue #69 · natural/java2python · GitHub
Open Graph Title: j2py not converting · Issue #69 · natural/java2python
X Title: j2py not converting · Issue #69 · natural/java2python
Description: Hi, I was attempting to use j2py to convert a simple Java program I made into python, but i got an error. This is the Java code: import java.util.Scanner; public class areaCalculator { public static void main(String[] args) { Scanner inp...
Open Graph Description: Hi, I was attempting to use j2py to convert a simple Java program I made into python, but i got an error. This is the Java code: import java.util.Scanner; public class areaCalculator { public stati...
X Description: Hi, I was attempting to use j2py to convert a simple Java program I made into python, but i got an error. This is the Java code: import java.util.Scanner; public class areaCalculator { public stati...
Opengraph URL: https://github.com/natural/java2python/issues/69
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"j2py not converting","articleBody":"Hi,\r\n\r\nI was attempting to use j2py to convert a simple Java program I made into python, but i got an error.\r\n\r\nThis is the Java code:\r\n\r\n```java\r\nimport java.util.Scanner;\r\n\r\npublic class areaCalculator {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner input = new Scanner(System.in);\r\n\t\tSystem.out.println(\r\n\t\t\t\t\"Hello. I am a calculator that can calculate the area of shapes. All I need is for you to input what shape's area\\nyou would like to convert from the following list: \\n\");\r\n\t\tSystem.out.println(\"•triangle\\n•circle\\n•rectangle\\n•square\\n•trapezoid\\n\");\r\n\t\tString shapeName = input.nextLine();\r\n\t\tif (shapeName.equals(\"triangle\")) {\r\n\t\t\tSystem.out.println(\"What is the base of the triangle? \");\r\n\t\t\tdouble triangleBase = input.nextDouble();\r\n\t\t\tSystem.out.println(\"What is the height of the triangle? \");\r\n\t\t\tdouble triangleHeight = input.nextDouble();\r\n\t\t\tSystem.out.println(\"The area of the triangle is: \" + (triangleBase * triangleHeight) / 2);\r\n\r\n\t\t} else if (shapeName.equals(\"circle\")) {\r\n\t\t\tSystem.out.println(\"What is the radius of the circle? \");\r\n\t\t\tdouble radius = input.nextDouble();\r\n\t\t\tSystem.out.println(\"The area of the circle is: \" + Math.PI * Math.pow(radius, 2));\r\n\t\t} else if (shapeName.equals(\"rectangle\")) {\r\n\t\t\tSystem.out.println(\"What is the height of the rectangle? \");\r\n\t\t\tdouble rectangleHeight = input.nextDouble();\r\n\t\t\tSystem.out.println(\"What is the width of the rectangle? \");\r\n\t\t\tdouble rectangleWidth = input.nextDouble();\r\n\t\t\tSystem.out.print(\"The area of the rectangle is: \" + rectangleHeight * rectangleWidth);\r\n\r\n\t\t} else if (shapeName.equals(\"square\")) {\r\n\t\t\tSystem.out.println(\"What is the length of one side of the square? \");\r\n\t\t\tdouble squareSide = input.nextDouble();\r\n\t\t\tSystem.out.println(\"The area if the square is: \" + Math.pow(squareSide, 2));\r\n\t\t} else if (shapeName.equals(\"trapezoid\")) {\r\n\t\t\tSystem.out.println(\"What is one of the bases of the trapezoid? \");\r\n\t\t\tdouble tBase1 = input.nextDouble();\r\n\t\t\tSystem.out.println(\"What is another of the bases of the trapezoid? \");\r\n\t\t\tdouble tBase2 = input.nextDouble();\r\n\t\t\tSystem.out.println(\"What is the height of the trapezoid? \");\r\n\t\t\tdouble tHeight = input.nextDouble();\r\n\t\t\tSystem.out.println(\"The area of the trapezoid is: \" + (tBase1 + tBase2) / 2 * tHeight);\r\n\r\n\t\t} else {\r\n\t\t\tSystem.out.println(\"Sorry. An error occured. Please try again\");\r\n\t\t}\r\n\t}\r\n\r\n}\r\n```\r\nWhen I try to run `j2py areaCalculator.py`, it returns this error:\r\n\r\n```\r\n# ERROR runTransform: exception while parsing\r\nTraceback (most recent call last):\r\n File \"/usr/local/bin/j2py\", line 120, in runTransform\r\n tree = buildAST(source)\r\n File \"/Users/vasan/Library/Python/2.7/lib/python/site-packages/java2python/compiler/__init__.py\", line 15, in buildAST\r\n lexer = Lexer(StringStream(source))\r\n File \"/Library/Python/2.7/site-packages/antlr_python_runtime-3.1.3-py2.7.egg/antlr3/streams.py\", line 336, in __init__\r\n self.strdata = unicode(data)\r\nUnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 362: ordinal not in range(128)\r\n```\r\n\r\nCan someone please help me figure out what the issue is? Thank you!","author":{"url":"https://github.com/MrKomodoDragon","@type":"Person","name":"MrKomodoDragon"},"datePublished":"2020-11-16T22:45:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/69/java2python/issues/69"}
| 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:0dab8cec-a061-c203-bac2-aeddb5011ca6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ED72:70D32:1B86A08:2622D26:6973B4EF |
| html-safe-nonce | d04b5c70e7c40b531a96e2d7ffdec25223f7427ffb501d4e4fa3d7df9edf3ecc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDcyOjcwRDMyOjFCODZBMDg6MjYyMkQyNjo2OTczQjRFRiIsInZpc2l0b3JfaWQiOiI0MjMzMTQ4ODMyNzUwNDgyNjcxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9f4801783e7d5e2cfef7f444b6b66ab96dac3723de076d035edc5497368177ff |
| hovercard-subject-tag | issue:744260019 |
| 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/natural/java2python/69/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fda60c578d0633d6975da4ea3b28564dad4eae69ef54a316f34e4dc97c4bd77b/natural/java2python/issues/69 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fda60c578d0633d6975da4ea3b28564dad4eae69ef54a316f34e4dc97c4bd77b/natural/java2python/issues/69 |
| og:image:alt | Hi, I was attempting to use j2py to convert a simple Java program I made into python, but i got an error. This is the Java code: import java.util.Scanner; public class areaCalculator { public stati... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MrKomodoDragon |
| hostname | github.com |
| expected-hostname | github.com |
| None | c583cf2a26ee9c2cb1cb0fab5c726ed6719c2c4c87fc0c7c38069132f28faf12 |
| turbo-cache-control | no-preview |
| go-import | github.com/natural/java2python git https://github.com/natural/java2python.git |
| octolytics-dimension-user_id | 146692 |
| octolytics-dimension-user_login | natural |
| octolytics-dimension-repository_id | 3298542 |
| octolytics-dimension-repository_nwo | natural/java2python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3298542 |
| octolytics-dimension-repository_network_root_nwo | natural/java2python |
| 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 | 53344dea98f729e752d2fa6a8cba0f99032ced49 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width