Basically, for a project i'm thinking of making a macro recording application, with a gui. It doesn't have to be brilliant, just basically functional. Are there macro api's for java? Ideally i'd like to use java, its where most of my limited experience lies. If not then what other languages could be recommended?
I'm using linux myself and was alerted to the xMacro terminal app. what id like is the basic record/play of this with a gui. Any ideas?
For capturing actions outside the java application, you will need to use JNI, since Java doesn't supply the appropriate tools to do that. So you should consider doing that in another language.
Related
I'm looking to get started with javafx and fxml, without downloading netbeans (as the official docs suggests: https://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm), eclipse or scenebuilder. I'm looking to use a simple text editor and terminal, similar to the way someone might create an html,css and javascript project. Is this possible, or is the only way to use fxml and javafx through netbeans or some other similar tool?
Technically speaking, in any programming language, IDE is always optional.
You can write all your source codes (.java, .css, .fxml) files using any text editor that you like (like Notepad++), then go to a command-line interface (i.e. terminal, command prompt etc) and compile them, pretty much like how you would compile a Swing application.
The advantages of doing so? Pretty much simply because you can do this without any unnecessary downloads.
The disadvantages? You have to be VERY VERY clear on every single details about Java and JavaFX.
You need to be extremely familiar with building and compiling Java applications manually. You need to do your own build path in order to compile right.
There is nothing there that will instantly tell you that you have made a mistake (be it minor or major, or even a typo). You will only see where went wrong after you re-compile via command-line.
You have to do your imports manually (in both java and fxml). This means that you would have to know the exact package names and class names.
Most of the time, you would have to imagine how your application would look like visually. The only time if you know you designed right is when you re-compile and run it via command-line.
HTML, CSS, Javascript are considered scripting language. This means that these codes do not require code compilation, and that there is a base application/process that is running in the background to interpret what you wrote in English terms (or at least it is very close to English).
Languages like Java are true programming language, they require you to compile them, and running them will most likely create a new process on the OS.
So the conclusion is, it is definitely possible to do so, but you would probably end up using 10x (if not 100x) more time doing the same thing. IDE is there to help you do some of the tedious things. If you really want to do it using the traditional command-line method, ask a new question on that.
I need to 'crash test' a couple of Java applications with mainly Javascript.
By crash test I mean I need to pass the Java class or method all different types of random inputs until it crashed then record it. But I have ran into the problem that I don't know the most efficient way to call a certain Java class or method from Javascript.
Then I also do not know which scripting language would be better for the job, python or javascript. Both languages have to work offline and I don't know if I will have access to the command prompt / admin privileges to use the command line to call the classes or methods. So what do I do?
2 Questions:
How do I call Java classes and Methods in Javascript?
Would python be better for this job?
How do I call Java classes and Methods in Javascript?
Java runs in JVM, Javascript runs in Javascript engine like v8. so first you need a layer which Java and Javascript can both run in. For now there are some ways to run Javascript in JVM, these ways all provide interoperability between Javascript and Java. you can Google 'Javascript JVM' to go ahead.
Would python be better for this job?
'better' depends on much. for programming language, I like Javascript. Javascript and the libraries mainly designed for web development, Python is more like a common programming language. also Python cloud run in JVM with help of JPython
I want to create a mod for Minecraft, and I am aware it uses Java. I am currently learning JavaScript, and was wondering if I am able to use JavaScript for the SDK.
Yes and no.
Java is not Javascript...but a Java project can interpret Javascript
Java and Javascript are two completely different languages. However, there is a javascript interpreter created in Java, that you can plug in to java, called Rhino. However, although Rhino makes it easier to embed Javascript into your Java code, its not a simple drop in solution that would allow you to simply script what ever you want with out going through the effort of makin the proper connections. Definitely achievable, but you wont likely be able to start scripting without making that time investment to connect Java and Javascript.
Background story
The relationship between Javascript and Java is a rather shallow one. The similar name comes from a marketing plan back when it was being released by Netscape (which most developers ended up moving to the non-profit Mozilla). They made a deal with Sun (bought by Oracle) to share that similar name, but purely for marketing purposes.
Yes, it is possible to run JavaScript within a Java program, using the Rhino Javascript engine (for example).
However, this would not be a good way develop a Minecraft plugin / mod. None of your knowledge of the Javascript APIs would be relevant. Everything you did to interact with Minecraft would entail using Java classes and methods in the Java or Minecraft libraries.
My advice:
If your aim is to avoid learning Java ... don't be lazy. (You'll end up having to learn the Java APIs anyway. And learning another language will be good for you ... assuming you aspire to be a professional programmer.)
If your aim is to integrate some pre-existing Javascript code-base, it might work. But you might be better off porting the Javascript code to Java.
Sorry, Java and JavaScript are totally different languages. The "Java" in both of them was a marketing decision from ancient times.
They do share some of the same syntax that many languages share, however, so if you have learned JavaScript it might be a little easier to get started with Java. They are definitely NOT interchangeable, though.
Have a look at JDK1.6's ScriptEngine, the interface whose methods provide basic scripting functionality. Using these methods you can execute javascript. Numerous examples can be found on usage of this.
script support is avail from jdk 6 onwards:
reference link
However, this is not a full implementation of Rhino.
I am thinking about writing a Java application where the user can write some modules in Java and add them to a library in this application. The modules will be some calculations that use data from the main app. Maybe a bit like VBA in Office.
I would appreciate if someone would give me some hints where to start as I couldn't find something useful on the net.
Thanks in advance!
You can try to develop a module framework from scratch, if you wish.
However, if you are developing anything serious you should consider using OSGi.
Theoretically it is possible. You can allow user to write java classes, then you can compile the class using java compiler, generate .class files. you can load them using your custom class loader (probably URLClassLoader or its subclass, etc.
BUT
It is very serious application. Actually it is a kind of IDE. So, of you really want this check out a possibility to create Eclipse based application, i.e. implement several eclipse plugins.
Other approach may be to allow user wring code in one of popular scripting languages. For example groovy that has java-like syntax but can be run without compilation and does not require creating classes etc. Javascript is an option too. Javascript interpreter is a part of JDK, so you even do not need external dependencies.
you might be better off incorporating some form of jvm scripting language. Something like groovy, jruby or jython. Those don't need actual compilation and can be stored in your system as source. Plus they can be quite nice to write code in too. Groovy has the advantage of being a superset of java. (For the most part) you could just degrade to java code, and run it in the groovy interpreter.
I would like to be able to incorporate a simple game, written in Java as a component within a Flex Application. Am I crazy?
Flex can display HTML, and SWF, it can also call JavaScript - but can I incorporate an applet somehow?
I do NOT mean kludging it in as a sister component within a browser, but actually within the flex application itself, so that it could also run under Adobe Air, for instance.
No, Flash doesn't have a JVM. You would need to convert your Java to ActionScript somehow.
Running a Flex application inside a Java program is possible, not the opposite.
It might be possible to compile a Java Virtual Machine (if it's written in C) using Alchemy... but I don't think you want to go there, converting your code would be easier and cleaner ;)