Automated Python to Java translation [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Is there a tool out there that can automatically convert Python to Java?
Can Jython do this?

Actually, this may or may not be much help but you could write a script which created a Java class for each Python class, including method stubs, placing the Python implementation of the method inside the Javadoc
In fact, this is probably pretty easy to knock up in Python.
I worked for a company which undertook a port to Java of a huge Smalltalk (similar-ish to Python) system and this is exactly what they did. Filling in the methods was manual but invaluable, because it got you to really think about what was going on. I doubt that a brute-force method would result in nice code.
Here's another possibility: can you convert your Python to Jython more easily? Jython is just Python for the JVM. It may be possible to use a Java decompiler (e.g. JAD) to then convert the bytecode back into Java code (or you may just wish to run on a JVM). I'm not sure about this however, perhaps someone else would have a better idea.

It may not be an easy problem.
Determining how to map classes defined in Python into types in Java will be a big challange because of differences in each of type binding time. (duck typing vs. compile time binding).

Yes Jython does this, but it may or may not be what you want

to clarify your question:
From Python Source code to Java source code? (I don't think so)
.. or from Python source code to Java Bytecode? (Jython does this under the hood)

Related

Java decompiler and editor for quick modifications [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am trying to find a Java decompiler just like swf-decompiler, that allows to edit and recompile the source, without having to export it anywhere, and do any external actions. What I want is to very quickly apply small changes to .jars and save them, without taking extra time on manually recompiling java code with other tools, Is there a decompiler like that? Is there anything similar (like .class variable editor) and is it even possible to make a Java decompiler like swf-decompiler?
Recommending a tool is offtopic, but as for the question of whether it is possible, the answer is yes and no.
Java is relatively decompiler friendly, so for simple cases, it should be possible to create such a tool. However, there are some features or patterns that tend to trip up current decompilers, and given the complexity of the language, there is unlikely to ever be a decompiler that can reliably roundtrip arbitrary Java.
Furthermore, while compiling Java loses a lot less information than C, it does lose information. Obviously, you'll lose stuff like comments and whitespace, but under default settings, you'll lose a lot more: local variable names, flags, and types, generic types, compile time annotations, etc. Most of this information is preserved to some extent for reflection purposes, and passing the -g flag to the compiler can force it to save more information, but you can't get it all back.
So in short, you can do a reasonable job most of the time, but you can't ever do it perfectly all of the time.
Also note that this is for ordinary Java compiled yourself. If the classfiles were not originally written in Java or they are obfuscated at all, you can forget recompiling. Even when decompilers produce readable output, the output is unlikely to be recompileable.
If you want to modify arbitrary jars, what you need is a disassembler and assembler. The best one I know of is Krakatau (Disclosure: I wrote it). The advantage of this is that it will work for any classfiles, even if they are obfuscated. However, it is not user friendly at all. If you don't know your way around the classfile format and bytecode, you won't be able to make more than trivial changes (such as changing a constant string).

Learning java for android: do docs at android site also cover native java libs [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I am learning java for first time. I have found it's very similar to haxe and flash as3.
However, i am also learning android. And in that i have learned that android overwrites many native java libs to improve speed or something.
Now this creates a problem...i am learning java separately because tutorials about android assume you know java. And this means continuing this path will result in me learning it one way and then the right way. Wasting brain...
So can someone clear confusion. Are all libs covered at http://developer.android.com/reference/packages.html ...or java in android also support more native libs. How would i know which libs are added/overwritten by android into native libs..
also can you suggest what libs/methods i should know to be not stuck at every step.
By libs i mean packages and methods.
Look here for Android Tutorials and docs, and use the reference you've already found.
http://developer.android.com/training/index.html
You may find it goes smoother if you finish learning Java first. The GUI is completely different from Java, but works well. Some Java Classes from older Android API levels are missing some methods, but that is all documented in the developer reference.
Learn Java, skip the graphical / GUI part and you're fine, I think. You can use almost everything from plain java. There are just minor differences like using threads. But that's nothing to worry about.

php equivalent to jython? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
i wonder if there is a php equivalent to jython so you can use java classes with php?
thanks
http://www.caucho.com/resin-3.0/quercus/
http://php-java-bridge.sourceforge.net/pjb/
I'm not quite sure what you are asking, since you are talking about two completely different things: a PHP equivalent to Jython, and accessing Java classes from PHP. So, I'm going to answer both.
Jython is a Python implementation for the JVM. So, the PHP equivalent would be a PHP implementation for the JVM. There are actually two that I know of: IBM's P8, which is part of Project Zero and Quercus.
However, you don't need to run your PHP on Java if you want to run it with Java. A PHP-to-Java bridge would be enough, you don't need a PHP-on-Java implementation. I know that at some point in the past at least one such bridge must have existed, because someone once told me that they used one, but that is about all I know.
I just googled php jvm and got a bunch of hits. Never tried any of them.
Well: Java Server Pages (JSP) are "equivalent" to PHP, but using java classes.
It's "equivalent" in that it's HTML with embedded java code, but not at all compatible to PHP syntax.
Fayer,
Try PHP/Java Bridge that integrates PHP and Java, as recommended in PHP manual (Java Class - dead- URL: www.php.net/manual/en/java.installation.php).
Please, let me know how it worked for you.
You may have to use Zend Server CE (www.zend.com/en/products/server-ce/), instead of Apache.
Best.

Where can I find a Java library for code highlighting? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm trying to find a Java library to highlight code. I don't want to highlight Java code. I want a library that will easily allow me to highlight a macro language of my own, in a code editor of my own written in Java.
JSyntaxPane is decent. Advanced and decent IDEs use either Lexer/Parsers such as Antlr and Javacc or regular expressions. Implementing it correctly is not a trivial task.
As you mentioned "a macro language of my own", I suggest taking a look at Lexer/Parser generators for Java and maybe JEdit syntax package source code(google it, reached the maximum hyperlinks) for lexing strategies.
GesHi is pretty good. There is a list of highlighters here.
UPDATE: missed that you wanted a java lib. Try jedit syntax package.
You might look at the Java port of GeSHi named JaSHi. It looks like it is a complete rewrite of the popular PHP package, with Java bindings.
JSyntaxPane may be the way to go. It will highlight a number of languages and is extensible to handle others.
You may want to take a look at xtext - it does a lot more than syntax highlighting; in fact, you only have to define a grammar, and it will generate an eclipse editor plugin with outline, syntax highlighting, syntax checking and autocompletion automatically. It could save you a lot of work if an eclipse editor plugin is an acceptable end result for you.

Online compilers/runtime for Java, C++, Python and ObjC? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Does anyone know of a good online compiler/runtime (for C++, Java, Python, ObjC etc.) that I can access on the web?
What I'm looking for is something that would allow me to type in a program in a web form and to run the program and see the results online.
(Let's not get into the why for now. Suffice it to say for the moment that I don't always have access to a compiler/runtime, and firing up an IDE is just overkill for testing out some code snippets)
I know of codepad.org -- but I'm looking for something better.
ideone is something better but what particular advence do you need?
http://codepad.org/
codepad.org is an online
compiler/interpreter, and a simple
collaboration tool. Paste your code
below, and codepad will run it and
give you a short URL you can use to
share it in chat or email.
Languages:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
Right now, you can use http://sagenb.org. This is a free open source online Google Docs-like programming notebook environment, which I provide (thanks to a generous grant from the National Science Foundation). Once you create an account and create a new worksheet, click on the box (fourth from left) labeled "Sage" and change it to Python. Now all the code you type in is evaluated using Python. The main drawback is that there are well over 30,000 users of this resource, so sometimes it is slow.
I found this online java compiler and runner. It works in realtime and also with threads. Amazing !
http://www.browxy.com
For C++, you could try CodeControl, Comeau or the one from code.vcer.net.
This one is good for ruby.
Here is an open source one: http://codenode.org, which supports Python and Sage well, but also aims to support other languages like Ruby, R, etc. Probably the best description of Codenode is "Google docs combined with Mathematica Notebooks".
CodeIDE is an ok one: http://www.codeide.com/
You can practice your SQL here.

Categories

Resources