Compiling .jar files lazarus / 6-IDE-CodeTools ---------------------------------------------------------------------- Danail · 2007-02-22 13:52 The main proud of the JAVA programmers is that their programs can be compiled into a platfrm independable .jar files. It will be nice there to be developed tool or a compiler option that compile the source dcode as a .jar file. ---------------------------------------------------------------------- matthijs · 2007-02-23 16:11 Why would you want to create a Java file from lazarus? jar files are more or less tokenised instructions which are interpreted by a virtual machine. What would be the advantage to create a jar file from pascal code, compared to creating a stand alone executable for any platform you want? ---------------------------------------------------------------------- Danail · 2007-02-23 16:51 Many PC's today with diferent platforms execute .jar files, so the .jar file can be used like a multiplatform executable, something like the .pdf file can be used on many platforms. ---------------------------------------------------------------------- felipemdc · 2007-02-23 18:09 It do is possible to compile common pascal code into Java bytecode. I already did a pre-eliminary investigation on this. There is a open source assembler for Java called Jasmin. With it, one should be able to add a new architecture to Free Pascal using the Java Assembler, and then create a new run-time library using Java standard classes. However, this work needs to be done by somebody, so feel free to send patches =) ---------------------------------------------------------------------- Zorba · 2007-02-23 19:19 Quote from: "Danail"Many PC's today with diferent platforms execute .jar files, so the .jar file can be used like a multiplatform executable That is the aim of java is be multiplatform. I think you want one file that runs on many architectures no? But no point in taking an executable (C++ or Pascal compiled executable) and turn it into java, if you need java then learn java. Already Freepascal targets quite a few systems and AFAIK the end result is a compiled program that runs directly on the architecture it was built for. That makes them much faster than Java programs that have to run on the Java Virtual Machine. For this very reason, java programs are much slower than compiled programs, so there is a penalty so to speak for that strategy (one file runs on all systems that have JVM). Heck you can optimize compiled code by processor type which makes it even more specific but increases preformance. ---------------------------------------------------------------------- Danail · 2007-02-24 11:40 Sekel, how can I compile the Pascal code to Java? Is there such a compiler and how to get it? I want to ask you if there exists and the opposite thing - a Java to Pascal compiler? ---------------------------------------------------------------------- felipemdc · 2007-02-24 14:42 > Sekel, how can I compile the Pascal code to Java? There is a pascal to j2me compiler here: http://en.wikipedia.org/wiki/MIDletPascal If you want to compile pascal to j2se bytecode, and not j2me, then you have to write a new compiler or enhance free pascal to do it. > a Java to Pascal compiler? Pascal is not a binary format, so this cannot exist. The best that could exist is a Java to Pascal language converter, but I'm not sure what you mean. ---------------------------------------------------------------------- Danail · 2007-02-24 17:39 This is what I mean? Is there such converters - for Pascal to Java or from Java to Pascal? ---------------------------------------------------------------------- felipemdc · 2007-02-24 18:10 I don´t know any. ---------------------------------------------------------------------- Danail · 2007-02-25 07:24 No problem However if you meet such somewhere in the web please post it. ---------------------------------------------------------------------- maxkleiner · 2007-03-06 22:31 Is it absolutely necessary to create Java byte code by compiling Java source code? I don't see so much problems in translating the following Pascal code to the byte-code following: function addTwo(i,j: integer): integer; begin   result := i + j; end; iload_1   // Push value of local variable 1 (i) iload_2   // Push value of local variable 2 (j) iadd      // Add; leave int result on operand stack ireturn   // Return int result But think in practice, e.g. you want to convert a dll to java, you have to use the jar format as well but it will never produce a dll as we know the binary.  Java also is a package-oriented language. It will be much easier to create Java packages from a package developed in such language like Pascal or Delphi. ---------------------------------------------------------------------- Danail · 2007-03-08 07:48 I am seeking for a program that does something like that you are talking about: To receive a pascal source code and to export as a result .jar file or .java file or java byte code. Manually converting is a nice idea, but takes alot of time. I am also looking for the oposite java source code to be converted to pascal source code. If you know such program please send me a link to it. ---------------------------------------------------------------------- anonymous coward · 2008-09-07 20:56 I don't think this would really make sense. How would you effectively support pointers? If you didn't, would it be practical to make a subset and drop some pascal libraries? Would it even be worth it? I mean you couldn't even use Java's class library without breaking compatibility. Edit: I didn't realize that this was inactive :oops:. ---------------------------------------------------------------------- Troodon · 2009-02-11 20:43 Quote from: Danail on February 22, 2007, 02:52:42 pmThe main proud of the JAVA programmers is that their programs can be compiled into a platfrm independable .jar files. .jar files are bytecode, not compiled (=native) code. They are almost like scripts. A "JIT compiler" is required to execute .jar files. That is why they are slower than Lazarus applications. If what you want is multiplatform (non-compiled) code you can choose from Java, Perl, Python, etc. There is even a free Pascal interpreter, PascalWorks. ---------------------------------------------------------------------- Leledumbo · 2009-02-12 04:55 AFAIK Felipe is working on FPJava, a compiler for Pascal subset that produce Java assembly code (let's call it that way, though it may have another name) which then get assembled by jasmin. Try asking him. ---------------------------------------------------------------------- bee · 2009-02-12 06:35 I couldn't see any good reasons to compile pascal code into java byte code. If you want multiplatform support, then pascal supports many well-known platforms already, even on some mobile devices. If you do like Java and bare to take all the consequences, you better go with Java. The main proud of pascal programmers is that pascal produces highly optimized and relatively small native executable for each platform from same single source and the executable can be run without any dependencies to gigantic virtual machine. Pascal and Java has very different concept on deployment. While Java brings "write once, run everywhere", Pascal brings "write once, compile everywhere". Which better for you? Choose based on your application requirements. ---------------------------------------------------------------------- Troodon · 2009-02-12 15:40 Quote from: bee on February 12, 2009, 07:35:16 amThe main proud of pascal programmers is that pascal produces highly optimized and relatively small native executable for each platform from same single source and the executable can be run without any dependencies to gigantic virtual machine. That, and the excellent (Delphi-like) IDE, is why I chose Pascal/Lazarus/FPC.