Easily exporting python to someone without the interpreter - java

Suppose I have a group of people to whom I want to show my python program. I don't want to have to tell them each "Ok, go to the python website, install the interpreter, open IDLE, open my program, press F5, and then it will run". Is there some way I can just send them a file of some format and they can run it easily?
I was thinking in the way of embedding it into Java, but the solutions I've seen for that seem to still require the python interpreter to run it.
P.S. I'm new to python, so I would be extremely grateful if responses aren't too technical and confusing. :)

I like cx-freeze for simplicity, but PyInstaller is also easy to use. Py2exe may be the traditional solution, but it hasn't been updated in 3 years.

One of the traditional solutions is: http://www.py2exe.org/

Related

Using SymPy (or another CAS) with Java

I am currently developing a project in JavaFX that accepts a mathematical expression and evaluates it. I have managed to get basic operations and a good deal of algebra to work. I have also managed to perform definite integrations using the trapezoid rule.
The main problem I am facing is with indefinite integration. I looked up many symbolic computation libraries online like JCalculus, JavaCalculus, JScience, SymJa and others. But none of them were as good as SymPy in terms of functionality. I wanted to know if there is a way to send commands to SymPy from Java and receive the result back into Java.
I am thinking of providing an installer for my JavaFX app that will install Python and SymPy if necessitated by the solution. I also tried to understand Jython, believing that it would somehow by related to the problem but I could not understand its purpose and its usage.
Please help me. I am quite good at Java and JavaFX but my knowledge of Python is severely low and restricted. Step by step instructions and sample code is extremely appreciated.
Thanks in advance.
If you somehow manage to write sympy equivalent python code from your java input in a file, you can get the output of that code very easily.
Process p = Runtime.getRuntime().exec("python yourfile.py");
Take a look at this.

Convert compiled VB program to Java to use in Android app.

I have several VB programs that I wrote a few years ago in school. Is there any way possible to convert those programs to Java? Or would that it be easier to just rewrite it from scratch? My goal is to create an Android app that combines at least two of the programs into one functional app. This is purely a nonprofit endeavor; I'm a full time firefighter and am looking to put a free tool in the hands of my guys and other firemen who might want to use it.
I've been unable to locate the source code for the programs and have searched for an answer but haven't been able to find a definitive answer as most answers cover the source, not the compiled result. I've downloaded a couple supposed VB decompilers to see the results, but, in order to see the 'full' results, all the ones I've used require purchasing a 'pro' version. I have no problem paying for such a version, but I'd like to know if it's going to work properly before I do.
It would definitely be faster to rewrite them than it would be to devise a way of converting a VB program into Java code. Not only are the languages quite dissimilar, but VB's UI model is nothing like Android's, so it would likely be impossible (or at least impractical) to translate the UI code automatically.

How to start out hand coding Java

I've just started with Java and I have been using Netbeans. I have tried Eclipse but it kept crashing on me and I gave up. Since then I have produced a small application, but I find that I feel very restricted within the development environment, and I see lots of generated code that I really don't understand, and which seems to bear little resemblance to any code I may find while researching a problem.
With this in mind, and having seen many suggestions, I would rather begin to code by hand so that I understand exactly what is going where, and why.
My question(s):
I have seen and read through a great many tutorials but most of them assume a certain level of competency. I've built a small desktop editor in Netbeans, but I've never coded Java by hand. With that in mind could you suggest a good "getting starting" tutorial for me?
I would also like some advice on a coding environment. I will be creating desktop applications and am already familiar with Geany through coding in Python, but I've seen very little information about Geany and Java.
I'd appreciate any suggestions about this, because there seem to be a great many editors available, but please note that I am using Ubuntu on my development machine. Open source is not a requirement, but being free is.
BTW, I have no problems with trying Eclipse again if that seems to be the general consensus, I am currently just a little jaded on it since I have never successfully even tested anything without a cataclysmic crash.
Many thanks for any advice that you can give.
MVK
A Little Update
Many thanks to those of you who have taken the time to give an answer. I am currently playing about with the Sublime editor, suggested by user1432824, having had another try at Eclipse. Unfortunately though, Eclipse has a habit of crashing when saving files which is rather inconvenient. I plan to chase this up and see if there is a fixable reason, but it still feels a little heavyweight and integrated and I really want to move away from that if possible.
Thanks for the tutorial links, I've seen most of them already in my travels, but I'm happy to get more.
Finally
Many thanks for your input, I think that I have come to a comfortable result, with a few loose ends that Ill check on later. Here are my findings so far:
The Sublime Editor:
This was a tricky one. The Sublime editor is actually an excellent little app (despite how it looks out of the box!) and I have little doubt that I will use it at some point, but for now it lacks something for me, although I would be hard pressed to explain exactly what. Thanks for the suggestion though, its always good to find new editors.
Eclipse:
So I took the plunge and tried Eclipse again, and, just like the first time I used it I've been rather impressed with the overall look and feel of it, however, just like the last time it crashes at the most inopportune moments and despite much searching I have yet to discover the reason or the cure, which leaves Eclipse out of the running. Besides, although I like the feel of Eclipse it is still a bit on the heavyweight side for what I want to do.
BlueJ:
I admit that I did not try this program, although thanks for the suggestion. It seems to me like just another IDE and I really want to move away from the whole IDE thing for a while, at least until I understand a little more about how Java actually works.
Many thanks for your suggestions, but I think for now that I will go with Geany for a few reasons: As a very lightweight editor it can compile and run Java from the menu or keyboard, which just saves some time, and I have become addicted to the Snippets function which comes in handy once you have learned the basic syntax of whatever commands you add to it.
The only other choice now is between ANT and Maven and I think that the only way to decide between the two is to use both and see which one 'feels' better to me.
Many thanks to all who responded and my final question must be: Since you have all helped me reach my final decision, how to I go about accepting this question? Any advice on that front would also be helpful!
regards,
MVK
In my opinion, if you are new to Java, don't start with GUI. Start with simple text application. The best resource for beginners in my opinion is the official Java tutorial.
http://docs.oracle.com/javase/tutorial/
Good luck!
Have you looked at BlueJ ? From the website:
BlueJ is an integrated Java environment specifically designed for
introductory teaching.
BlueJ was developed at a University specifically for the purpose of
teaching object orientation with Java.
BlueJ is free!
I would strongly recommend using some form of IDE. It'll provide interactive debugging, hints, completion, code colourisation and useful error highlighting.
have you tried the Java online trainings?
http://java.sun.com/developer/onlineTraining/awt/contents.html
As for editors, I started out with a simple plain text editor like those that come on Mac and Windows. I also use Eclipse for Java Developers, and Sublime Text. Sublime has a free, unlimited trial, but will bug you every few saves to buy the premium version.
I would recommend that you get familiar with a build tool, like Ant or Maven. Once you have a project with more than 1 class in it, using a variety of libraries, it's good to have some help managing dependencies, running tests, building jars, etc.

Text to speech converter

I am going to create a Text to speech converter, which can be executed in both Windows, and Linux based systems. Can someone please help me answer the following questions;
What language should i use; Java, C++ or any other?
The program i am going to create should be able to read large chunks of data.
There should be good sound quality.
What are the libraries available to achieve this?
Please share your experiences as well.
Use the language you're most comfortable with. I learned the hard way when I tried to re-code my raytracer in C++, coming from a Python background. It took me weeks to get it to function...
Basically, you'll get frustrated by the nuances of a new language before you can get to coding something, so I suggest you stick with what you know.
That's independent of the language. Just makes sure to read the data in chunks (like 2048 kilobytes at a time). Reading a big file to RAM is not a great idea, as you can't be sure your end user has enough RAM (audio files can get BIG).
This is trivial. I can't help you program good sound quality. That's up to you.
There exist a few implementations of TTS for Linux, so that's all I can recommend. Look at Festival, as it is one of the ones you can actually understand.
Long time ago i had that same idea. I think it is not too complicated and can be done. This is how i would do it:
1- I would use Java, because it is platform independent.
2- If you are going to create an standalone application, it will be the local computer that will do the processing an not an application server, as in the case of web apps. Also i suppose that your program, will be used only by one user at a time. I think you will not have big issues with the amount data to process, if u implement some buffering mechanism.
3- The quality of the sound will depend in various factors such as: noise when recording,format, speed of the sound... Notice that many text to speech applications that exist on the web, the sound quality is ok, but you will never get the feeling that it is a real person, who is reading. (I recommend you a female voice, it sounds better).
4- Regarding to the libraries and another gadgets, this is what i think you might need:
-Java Standard Development Kit(To be able to work with java)
-A good IDE: There a many out there you can get for free. My favourite is eclipse but if you are a beginer with java, you might like to start with netbeans many people say it is more intuitive for learning.
-JLayer Mp3 library This will help you play the sounds in java.
-javax.swing Is a java library that is included in the development kit and allows you to create rich graphical user interfaces. Also if you are new to swing, i would recommend you a great swing IDE, called JFormDesigner, have a look at it, im sure it will speed your development alot(It is a great tool).
I hope my answers can give you some tips.
Update
I think it would be correct to mention also, that the only minimum requirement the users of your app will have in order to run the app is:
JRE(Java runtime enviroment)
This project of text to speech can be made using computer generated voice
so no problem of storing a database for each word and its pronunciation.
Just use the language in which u feel master to urself and apply the concept.....
I do not know anything about text to speech except that it's not easy. That being said, I suggest you stick with the language you are most familiar with. I'm sure Java and C can do it.

Most effective server side programming language for web development?

This is more a question of pros/cons between PHP and JAVA.
Iv been doing research, and iv narrowed it down to those two.
And in consideration, id like to go into mobile app dev...So thats +1 for Java.
Time taken to learn the language is not an issue...Just would like to know which is the most effective between the two languages mentioned above.
And on a slight note. Can Javascript work with Java? And what is the real advantage of that?
All answers are appreciated, thanks in advance.
I'm sorry, but PHP and Java are not the only choices. Ruby on Rails and Python's Django framework are both excellent tools for web development. While I haven't used it, Groovy's Grails framework is also very highly reviewed (largely by ex Java programmers). In certain (admittedly obscure) circumstances it's even advisable to do something off the wall like write a CGI program in C. It all depends on what you're trying to do.
Mobile app dev shouldn't influence your choice here, because no matter what web framework you're working with a mobile app is a whole new ball of wax.
So, here's the deal: asking people to compare PHP and Java really won't get you any meaningful answers -- you don't have the background necessary to understand what we'll say. You really need to figure out what you're trying to do before you choose your tool. It's like saying "I'm thinking about building a house, should I use a screwdriver or a hammer?" Here is what I would advise:
Go learn to program. Pretty much any language will do, but I'd suggest something nice like Python or Ruby. Spend a few months getting comfortable with programming first.
Pick a project. Make it something simple. When you know what your project is, pick a tool to use to complete your project. This may involve asking another SO question.
Rinse and repeat. Complete many projects. Once you've finished 5 or 10 web projects you'll be in a position to compare different tools. The more tools you use, the better. I'd suggest you do one in Ruby on Rails, one in PHP, one in Django (a python framework), and maybe even one in Java with JSP.
Once you've got that base of experience come back and ask this question again. You'll actually be equipped to understand the answers. Of course, once you've got that experience you won't need to ask the question because you'll already know the answer.
The one you know.
Some feedback:
Mobile app dev is not necessarily just web development.
Javascript is the language of choice on the web browser and works with PHP, Java, etc. on the server.
In general, one language is not more effective than another.
Seriously, judging by your post, I would advise you to start learning PHP and Javascript.
You already have a web browser so you can start writing javascript now.
As for PHP just install XAMPP from http://www.apachefriends.org/en/xampp.html and after a double click you'll be ready for web development.
After learning what its all about you'll be able to then check out Java and see if it is more effective in what you are trying to do.
Your question really indicate you need to learn alot about web development and programming in general, so I could answer your question but.. I'd recomend you go read up a little.
And in consideration, id like to go
into mobile app dev...So thats +1 for
Java.
How is that +1 for Java? We're talking about server-side languages.. you're not running your server off a phone are you? Sure, you can use Java to build apps in addition to running your website, but that's a different story.
Time taken to learn the language is
not an issue...Just would like to know
which is the most profitable at the
end of all the training.
Neither language will make your site more profitable, but you may be in higher demand with different companies depending on what you know.
And on a slight note. Can Javascript
work with Java? And what is the real
advantage of that?
Well... yes, but that's almost a nonsensical question. You use Java or PHP to produce the HTML that gets sent to the client, and then your JavaScript manipulates that. It's completely unrelated to what language you use server-side.
#comment: I can't really say which is more worth learning. I suppose Java is more versatile in that it has more applications outside the web. PHP is supported by more web-servers though (AFAIK), so you won't have trouble if you need to work on a different server.
I can't fairly recommend one over the other though. I've only used PHP for web, and Java for non-web. I like PHP because it's easy to pickup, easy to use, and all sorts of stuff is built into the language without any includes or anything. Has a big community, so there's lots of scripts you can download. One might argue that it's also a mess of a language, but as long as you aren't all uppity about that sort of thing, it's not really a problem. Java OTH... I don't know. I'm not a Java keener, that's all I'll say :)
Most of the answers here should be able to direct you towards your answer though I would just like to say if you are going to learn a programming language to make Web Apps learn Java, not because this will be the best tool for the job, each job is different, but knowing a full fledged language you will be able to quickly adapt to other languages.
You don't learn a language, you learn the concepts behind programming, then apply them to different languages.
I think you need to outline the context of your question. For example, if you are looking to get a job in IT, then the language that is most asked for in job ads is the one you want. If on the other hand, you have an application in mind that you would like to write, then you need to tell people (without giving away the details) what type of application it is so that they can tell you the most suitable languages/APIs to for that area.
But remember this - there is no such thing as a super programming language that is the best for everything. Each language is suitable for a range of tasks in a range of contexts, and is usually awful for everything else. Without the context of where the language will be used, no-one can tell you which is better.
Stop trying to kill two birds with one stone. There are different tools for different tasks. You can write mobile apps with Java but you can't write web apps with it. You'll have to use a server-side programming language such as PHP, Ruby on Rails, Django (Python), etc.

Categories

Resources