Compiling and running a C++ program from a Java application - java

i need to run a cpp propgram from a java application.
I have Visual Studio and Eclipse.
I have all of the cpp files and also a .mak file which i'm not sure about how it could help me...
any help or direction would be welcome!

Do you want to actually run the final application? This seems more like you want to build it.
Either way you can use:
java.lang.Runtime.getRuntime().exec(command, environment)
To run a process from Java like running it from a console.
See http://java.sun.com/javase/6/docs/api/index.html?java/lang/System.html for details.

Related

Making a Java Console Application

I wonder if it's possible to create a java console application where someone can download my packages, run and use that application in Command Line/Terminal or with some other console application.
I am very well versed in Java & the reason I'm asking is, I have a chess game which I have made to be run in command line, but how do I get it to run like an application?
To wit: On a mac, just like one who has Home brew can download formulas and use their specific commands to begin and run them, how can I do this for an already made application. Do I need a config file? Or is it just good to go as it is.
So I don't want someone to download the package and have to use the "javac/java" command to compile and run it, but can just say something like "run chess" and it does so. Any help or resources would be appreciated
You need to convert your .jar to .exe
There is a lot of software doing this, for example JSmooth.
You need to choose the starting application class and then run it.

how do i launch java coding from atom so that it opens the entire program from github in the terminal

So I'm working on a project as an intern and it involves atom and Github so I pulled the coding down to my desktop and have all of that set up. So how do I launch the code so that it will allow me to test the code?
You will want to make sure you have Java install on your machine, and the move into your directory, then compile the program by doing javac filename.java This should be the file with the main method in it. That will generate a class file, then you can just do java filename.
Alternatively, you could download Eclipse and import the project in and run the test in the IDE. This would also allow you to write your own tests, or modify them if you need. https://www.eclipse.org/downloads/ and the Neon version will probably work fine for you.

Is it possible to execute matlab script from java

I Have a java application.I want to run the matlab script from java. Is it possible to run matlab script without installing matlab but only using the matlab jar file in my application.
Please give some links or some inputs.
In one of my academic projects I used the following link and it works.
http://www.cs.virginia.edu/~whitehouse/matlab/JavaMatlab.html

Have a Java application (JAR) that needs to be executable. (Built In Eclipse)

I have this little application (JAR) built in Java on Eclipse and it needs to be compiled into an executable file that people can just double-click and it runs. Ideally this would an exe filetype. I'm not so versed with java and what the needs are but I'm hoping it can be compiled to run one computers that maybe don't have java installed.
Is there any advice or direction you can point me to so I can figure this out?
Many thanks.
Ideally this would an exe filetype.
No, ideally this would be a Jar file. Just leave it be a jar file. It will work fine if you set up your platform to respond to double clicks correctly. And yes the computer will need to have Java installed -- that's not an onerous requirement.
Try this application : exe4j : http://www.ej-technologies.com/products/exe4j/overview.html
It runs on various platforms to made EXE files :))
You won't be able to make it run on PCs without Java installed.
There are plenty of guides on how to make an executable jar to run on computers with Java installed: take your pick: java executable jar creation, Make JAR as a standalone executable and so on...
You can try http://www.excelsior-usa.com/jet.html. It is free for non-commercial use.

How to generate an exe file from my java project ? Which tool should I use?

I was asked to make a program (in java) by some person but I was stacked as I didn't know how to generate and exe file from my jar file... It would be useless If I install for them the jdk environment as this person don't how to program... Does anyone knows ho to do this or what tool should I use ?
Regards from Córdoba Capital, Argentina...Thanks in advance !!!
You could use launch4J, it's pretty simple to use and to configure.
Read this post, it may help
http://viralpatel.net/blogs/2009/02/convert-jar-to-exe-executable-jar-file-to-exe-converting.html
Regards
Thomas
Here is a post from earlier that has some other options:
How to create a Java application which can be run by a click?
As Lucas mentions above, you will need to install the JRE on the user's machine to get a Java app to run properly. If it is a small program, you could consider making a .bat file (or .sh file on *nux) to allow the user to run the program. Your bat file could as simple as the one below. Just put in a .bat file and add as a short cut. I know there are more elegant solutions out there, but this is simple and should work.
setlocal
set CP=<PATH TO ANY DEPENDENT LIBRARIES OR JARS>
start javaw -cp %CP% <FULLY QUALIFIED MAIN METHOD> <PROGRAM PROPERTIES>
endlocal
They don't need to install the entire JDK to run the jar file, all they need is the significantly smaller JRE. This is standard practice when distributing java applications.
A big advantage of running your java program on the jvm as compared to generating a native binary is that it will, assuming you aren't using a platform-dependent library, be platform-independent straight away.
You can use Excelsior JET. It is not free, work quite slow, but you can create executable (very huge executable). I tested it on Windows and it worked. But executable it created was slower then .jar run using JRE.
There is also GCJ. I tried it, but it was too hard for me to compile my project.
I suggest installing JRE and working with .jar file.

Categories