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: github.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:dfe97b1c-ec55-1856-af42-f53b65ce7daf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B744:2780A3:1421566:1BB365A:696A9513 |
| html-safe-nonce | f616679c5e87a7c3e44bb68029d16f296f5f0c215703e82c18bcb888709eb06b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzQ0OjI3ODBBMzoxNDIxNTY2OjFCQjM2NUE6Njk2QTk1MTMiLCJ2aXNpdG9yX2lkIjoiNDMyODc3MzI5ODg4ODAyMTI2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 729c5e4132ff94afc37dcd13d94edcfcb17c027085c610efe916650846b36cd8 |
| 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 | 4dd496afc954da9c207b2d9fbe86e3074619f565754aa1d9274aec30d9e5b8d7 |
| 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 | 31496a13b80a2f6ad77d6c617ee2255a3545b539 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width