I'm giving a presentation to a Java User's Group on Groovy and I'm going to be doing some coding during the presentation to show some side-by-side Java/Groovy. I really like the GroovyConsole as it's simple and I can resize the text easily.
I'm wondering if there is anything similar for Java? I know I could just use Eclipse but I'd rather have a smaller app to use without having to customize a view. What's the community got?
Screen shot of GroovyConsole:
DrJava is your best bet. It also has an Eclipse plugin to use the interactions pane like GroovyConsole.
try beanshell. its a scripting wrapper over java. http://www.beanshell.org/
Why not use the GroovyConsole ? Groovy accepts the vast majority of Java syntax
One good reason for not using something like the Groovy Console (wonderful though it is) is when you want to test what something would be like in Java, without actually going to the trouble of a boilerplate class and main method to run snippets of code. There are some differences between what Groovy does and what Java does. It'd be nice to have a simple way to test something and know for sure it will work when you put it in Java.
Related
I want to know that what would help me in the long run like what the industry's trend is?
Does everyone uses GUI builder, or is it like that java isnt popularly used for GUI and acts mostly as a background operations language?
please guide me..
IDE may not be enough for designing everything (but it helps lot in development), its always better to learn API and IDE both together.
I would learn Swing, because it is useful to know the general ideas of how it works. As for actually generating GUIs, I would use and IDE builder because it's faster. You may find that it's useful to know how to manually fix up the generated code, so knowing Swing would be useful. Often you want to customize how part of the GUI works, and you would have to use the language directly to do that. The IDE builder can be a useful tool for quickly building most of the GUI.
This is just a comment, I am no expert.
My Recommendation for Java is to learn how to do in swing manually.
However I am recently using the Windows Builder Pro that is included in the latest Eclipse Juno. And it creates the code, so you can go back to direct coding without compromise.
There must be better out there, but for my small and simple apps saves me time.
https://developers.google.com/java-dev-tools/wbpro/userinterface/
It is included in Juno just right click a JFrame type class and select Edit with Windows Builder.
You may use the IDE tool, create the code then see it and enhance or add as you like. But for a starter you can add a Full menu, buttons and several controls in no time while maintaining a single .java file.
I suggest you learn swing because GUI builders functionality is limited. But it is ok to use GUI builder if you are developing simple apps. I prefer coding my own UI
You should definitely go for Swing. Using an IDE may seem easy in the beginning but you have to remember that it is way too restrictive. And if you do end up learning swing you can take the thing to the next level, if you know what I mean. It also depends on whether you like to write code or not because if you don't then naturally swing will not interest you. Here's a tutorial. Hope it helps. :)
If you want to be a professional you'll need to master Swing along with all its nuances such as the LookAndFeel and Layouts. NullLayout was my favorite layout of choice while getting started, but you'll definitely need to learn GridLayout and GridBagLayout as well. Mastering the behavior and listener models will require work, but are a must for any mid-level and beyond GUI programmer.
The IDE builders are good for getting it started, but I would be leery of trusting the code that they generate, especially if you have to be personally accountable for it. Even if you must use an IDE WSIWYG you'd better make sure you know what its doing.
I want to run Prolog code using Java.
I found some engines, but the only one that seemed easly to use was w-prolog . However, when I tried to use it I figured out he doesn't support simple things like Lists or dynamic assertions.
I also saw tuprolog but it seemed far more heavy than I wanted and it seemed I need to recreate all my code in a Java syntax (separating terms, facts, etc).
I just want to run prolog from a file and read the result in Java.
Anyone knows how can I do it? Does tuprolog allows me to do it in a simple way?
I think that Jekejeke Prolog can do that. It's a 100% java written Prolog. Though, being a commercial solution, it may not be a fit for you.
Another option - particularly interesting for Asian countries might be Minerva.
SWI-Prolog JPL is a bi-directional Java/Prolog interface which works quite well. I've used this quite a bit (mainly calling Prolog from Java, but also the other way around) and the performance seems fairly good.
you can also take a look at my old project PROL http://igormaznitsa.com/projects/prol/index.html but it is not an opensource one yet
I am an iOS developer and I found a great library that handles all kinds of astronomy related calculations for me. The problem is that it's written in Java. Although I have enough experience with languages close to Java, I can't run Java on iOS.
I'd like to port it, but being that I've never ported anything before. Like I said, I don't think language will be the issue. It's a fairly simple library, involving mostly Date objects and math.
I'm trying to figure out the best way to do go about porting. Do I start with the core methods/functions of each class, or can I just go line by line in each file until I have translated everything?
Just start wherever you please. Generally, you'll want to start near the core, and work your way out. Just remember these three steps:
Make it work
Make it right
Make it fast/clean
So don't worry about getting it looking pretty or anything right off the hop, just get it working how it needs to, test it. Then look at where you can refactor if possible, etc.
Since this seem to be a library of functions, it would not depend on any platform specific functions.
Porting this should really be straightforward. You can port function by function, maybe start with functions that are important for your app.
The really tricky part (given it's a math lib) will be assuring that it works correctly: you should have the same set of unit tests as original lib. The best would be to create a java wrapper classes that call your lib via JNI so that you could run original unit tests on your lib. Pure Objective-C lib (no platform bindings) should run on both OS X and iOS, so you can run tests on OS X. Do something like this:
Look at original Java lib, and create functionally similar API in Objective-C: Same classes, same method names.
Take the original java classes and replace all content of methods with JNI calls to your native library.
Implement functionality in your lib.
Run java unit tests (which now calls your native lib) to make sure your lib works correctly.
For easier JNI development you can use JNA or any other JNI wrapper listed here.
I came across open-source project PHP/javaBridge for connecting php application with java. But why should I use java with php? Is there any specific advantage for this? Thanks, Robert
The main benefit is when you already have a lot of existing java libraries that you don't want to recode in PHP, but where you do want to build new applications using PHP
You may want to use a library that is in Java.
You wanna find the right tool for the job, not the right job for the tool. I guess you just shouldn't use it if you have to ask this question.
That said, there are a few good cases where you'll use Java with PHP, most of the times the big advantage is that the Java application keeps running on the background (as a daemon) and it's more powerful.
Do you really need to use Java? If so, go for it. Or are you just looking for new ways to do things? If so, don't bother. PHP is powerful enough to do what you need. So is Java. Pick one, and stick with it...
I need to implement a console application (possibly in Java) with ncurses-like functionality (such as navigating a menu and redrawing the whole screen).
The only solutions that I can find to do this so far are CHARVA ("A Java Windowing Toolkit for Text Terminals"), tuipeer ("A Text User Interface for the Java AWT") and a really old Dr. Dobb's article ("A Text UI for the Java AWT
").
So far, CHARVA is the best thing that I can find but I don't like the idea of it using JNI to wrap curses.
Is there any standard way, say with AWT/Swing, to do do this? What other alternatives are there?
Since 2010 there is Lanterna :
Lanterna is a Java library allowing you to write easy semi-graphical user interfaces in a text-only environment, very similar to the C library curses but with more functionality. Lanterna is supporting xterm compatible terminals and terminal emulators such as konsole, gnome-terminal, putty, xterm and many more. One of the main benefits of lanterna is that it's not dependent on any native library but runs 100% in pure Java.
More here: https://github.com/mabe02/lanterna
You may want to go vote for this issue here: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6351276
Essentially there is no good way to get ncurses-like functionality without JNI until this issue is addressed.
The short answer is deal with a Java wrapper around curses.
The long answer:
Terminals vary a lot, which is why terminfo/termcap libraries exist and why they are a mess to deal with (The maintainers of those projects are saints btw). They abstract away all the really basic terminal variations to something sane. Curses make those in nice efficient libraries to use.
If you want a pure Java solution, you'll need both those libraries or their equivalent in Java. I'm sure someone will point you to that if it exists, but I as far as I know it doesn't exist.
I'm using JavaTUI (http://sourceforge.net/projects/javatui/files/) in my several console java projects. It's best what i can find but it so far from perfect. I'm think there is not a good TUI implemetation in java world.
You can try Jexer - Java Text User Interface:
https://github.com/klamonte/jexer
I believe Jcurses is a native java implementation of the curses API, I recall it have a few quirks, but it should be able to do what you want:
http://sourceforge.net/projects/javacurses/
Try java curses (sorry it uses JNI). I also tried to implement a short version of this library just to learn JNI , see http://plindenbaum.blogspot.com/2008/01/java-native-interface-jni-notebook.html. One could also imagine a specialized JPanel displaying a matrix of characters:
public class TPanel extends JPanel
{
private Vector<Vector<YourCharAndStyle>> rows;
protected void paintComponent(Graphics g)
{
//paint the characters
(...)
}
}
I think it would be better to abstract your Java code from the TUI and use ncurses against several separated parts of your application or using arguments, in a web-services style. For example, code your TUI and when the user calls an action, use ncurses to call your code passing some parameters
java -Daction=doSomething MyApp
This way you can code your app using a GUI also in case you need to.