Haxe Compilation Failing

220 views
Skip to first unread message

bcp...@gmail.com

unread,
Jun 4, 2014, 5:59:35 PM6/4/14
to haxe...@googlegroups.com
I'm completely new to Haxe, coming from mainly from Java. I'm having trouble getting a simple hello world program running in Geany on Ubuntu 14.04 with Haxe 3.1.3 (and Neko 2 I believe) installed with the Linux installer.

My code:

class HelloWorld{
static function main(){
trace("Hello World");
}
}

The compile-time error:

haxe -neko "HelloWorld.n" -cp . "HelloWorld.hx" (in directory: /home/brexton/Desktop)
Compilation failed.
/bin/sh: 1: haxe: not found

What could possibly be going wrong?

Nathan Hüsken

unread,
Jun 4, 2014, 6:08:07 PM6/4/14
to haxe...@googlegroups.com

Not the expert here, but to me it seems like haxe is not correctly installed.

In my case the “haxe” executable is located in /usr/lib/haxe/ and in /usr/bin there is a symlink to it.

In your case it looks like there is a “haxe” bash script, which cannot find the correct “haxe” executable.

What does

which haxe

tell you? And when you look into that file, is it a bash script? What is line 1?

I am just guessing here … but maybe it helps :).

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

bcp...@gmail.com

unread,
Jun 4, 2014, 6:36:02 PM6/4/14
to haxe...@googlegroups.com
That suggestion that Haxe is not installed correctly makes sense, unfortunately, typing "which haxe" into the terminal (I assume that's what you wanted me to do) does nothing.

Jason O'Neil

unread,
Jun 4, 2014, 8:41:20 PM6/4/14
to haxe...@googlegroups.com
Hi

If you type "haxe" at the command line I'm guessing it will say command not found, I'm guessing the install didn't work.

Are you using the OpenFL installer or the tar.gz file off the website?  There was a period of a day or two when we launched the new website where the OpenFL install script broke, so that may have caused a problem for you.

Either way, there are some other methods for installing that might be good options for Ubuntu:

Once you get Haxe installed and working from the command line, then have another look at geany integration.

Jason

bcp...@gmail.com

unread,
Jun 4, 2014, 11:53:08 PM6/4/14
to haxe...@googlegroups.com, he...@jasono.co
So it wasn't installed, and I installed it with "sudo apt-get install haxe" (why isn't this the primary install method?) and it will compile, but my program exactly as above, does not print anything in the command line. Why?

Sven Bergström

unread,
Jun 4, 2014, 11:59:50 PM6/4/14
to haxe...@googlegroups.com, he...@jasono.co
You built a neko file, the HelloWorld.n is a neko executable.

You want to run this executable in the neko vm, use

neko file.n

bcp...@gmail.com

unread,
Jun 5, 2014, 12:09:38 AM6/5/14
to haxe...@googlegroups.com, he...@jasono.co
Oh... So I tried that command and nothing happened. What's wrong now? How can I compile it into a different language (like Java)?

Thanks so much to all of you for all of your help.

tom rhodes

unread,
Jun 6, 2014, 6:28:50 AM6/6/14
to haxe...@googlegroups.com, he...@jasono.co
have a look here for how to compile to java...

http://old.haxe.org/doc/start/java

also search this list for justinfront's java experiments, I think I'm right in saying he had some getting started with UI and haxe/java right?


On 5 June 2014 06:09, <bcp...@gmail.com> wrote:
Oh... So I tried that command and nothing happened. What's wrong now? How can I compile it into a different language (like Java)?

Thanks so much to all of you for all of your help.

--

j...@justinfront.net

unread,
Jun 6, 2014, 8:14:48 AM6/6/14
to haxe...@googlegroups.com

On 06/06/2014 11:28, tom rhodes wrote:
> have a look here for how to compile to java...
>
> http://old.haxe.org/doc/start/java
>
> also search this list for justinfront's java experiments, I think I'm
> right in saying he had some getting started with UI and haxe/java right?
>
>
> On 5 June 2014 06:09, <bcp7bcp> wrote:
>
> Oh... So I tried that command and nothing happened. What's wrong
> now? How can I compile it into a different language (like Java)?
>
> Thanks so much to all of you for all of your help.
>

bcp7bcp

Java swing and awt work out of the box with Haxe Java so they are an
easy place to start after follow the start tutorial above.

http://old.haxe.org/doc/java/graphics2d

If you don't care for graphics you can use Haxe stuff for reading and
writing files.

http://old.haxe.org/doc/sys/io/fileio

If you want to use external java libraries you can just use them with

-java-lib

But with complex libraries you may find some don't work for one reason
or another, but lwjgl seems to work well and will give you a OpenGl context.

You can find the hxml file related here

https://github.com/Justinfront/wwx2014_justinfront/blob/master/compile_lwjgl_BounceLogo.hxml

and setup here
https://github.com/Justinfront/wwx2014_justinfront/blob/master/src/wwx2014_justinfront/bouncinglogo/BouncingLogo_lwjgl.hx

https://github.com/Justinfront/wwx2014_justinfront/blob/master/src/lwjgljustinfront/Lwjgl.hx

I have put all the require lwjgl java libraries in the repository it's
setup for my mac so on windows or linux it will need adjustment if you
get really stuck I can look to improving this.

I also started porting some Java youtube examples of lwjgl use but lost
interest, but if you look at the original repository and the code I have
ported it should help you understand how to port standard java to Haxe java.

https://github.com/Justinfront/YouTube-tutorials-haxeJava

But certainly I advise you start with swing / awt as it should be
simpler that opengl to setup.

You might want to search for Andy Li github for some other haxe Java
stuff he has a blog post here and there will be some other haxe java in
my github.

http://blog.onthewings.net/tag/java/


Best Justinfront





j...@justinfront.net

unread,
Jun 6, 2014, 9:02:49 AM6/6/14
to haxe...@googlegroups.com
If your exploring Java target, other interesting aspects is you can have
several swing application windows, and you can use a BorderLayout or
similar to arrange panels on the screen. Using Canvas one of the panels
can be an OpenGL context it's often common to use swing/awt with
creation of images for the OpenGL for instance can be used for font.

Here is the sort of approach to getting a gl context in a panel.

panel = new JPanel();
panel.setLayout(new BorderLayout());
canvas = new Canvas();
try{
Display.setParent(canvas);
Display.setDisplayMode(new DisplayMode(640, 480));
} catch ( e: LWJGLException ) {
e.printStackTrace();
Display.destroy();
Sys.exit(1);
}
panel.add( canvas, BorderLayout.CENTER );
panel.setVisible(true);

You need to do a first render of your screen to get layout of elements
etc working then you can start the gl stuff so call the paint on the Jpanel.

Then

try {
Display.create();
Display.setResizable(false);
} catch ( e: LWJGLException ) {
e.printStackTrace();
Display.destroy();
Sys.exit(1);
}

Then go on to setup your Gl11 stuff as usual and then the while loop so
you need to do stuff in the right order to get layouts to work properly
it's quite easy to not see the OpenGL window if you get this wrong.

Other stuff on the Java target that is interesting is you can just use
an editor some snipits of code to give you some ideas

import javax.swing.text.rtf.RTFEditorKit;
import javax.swing.text.html.HTMLEditorKit;

enum FileTypes {
html;
rtf;
}

public inline function getFileType( fileIn: String ): FileTypes {
return Type.createEnum( FileTypes, fileIn.split(".")[1] );
}

editor = new JEditorPane();
editor.setBackground(Color.white);
var scroller = new JScrollPane();
scroller.getViewport().add( editor );
panel.add( scroller, BorderLayout.PAGE_START );


public function loadFile( fileIn ) {
var fileType = getFileType( fileIn );
switch( fileType ){
case rtf:
var rtf = new RTFEditorKit();
editor.setEditorKit(rtf);
try{
var fi = new FileInputStream( fileIn );
rtf.read(fi, editor.getDocument(), 0);
}catch( e: Dynamic ){}
case html:
var kitHtml = new HTMLEditorKit();
editor.setEditorKit(kitHtml);
try{
var fi = new FileInputStream( fileIn );
editor.setContentType("text/html");
editor.setEditable(false);
kitHtml.read(fi, editor.getDocument(), 0);
}catch( e: Dynamic ){}
}
}

Sorry I do have some working code for both of these but needs tidying up
and maybe the info is a bit vague to be useful.
Reply all
Reply to author
Forward
0 new messages