I wrote a java program by netbeans 6.9.1 and jdk 1.6. I don't want to use the output windows of netbeans because it's a bit slow. I am using Windows xp sp3 and I want to run by the cmd. I tried to find in the project properties -> run but nothing there.
If you run the project in netbeans it should ask you to pick the main class. In your case that is already done because there is a value of sample.Graph in the Main Class field.
Then do a clean and build and look at the output window. It should tell you what java -jar command to use to run the program on the command line.
Related
Is it possible to create a executable jar file coded in java12 while java8 is still installed?
We use java8 in university but privatly im coding in 12 and so i need to find a way to run a private coded program through a jar file (created with artifacts through intellij) but still keep the java8 installment for university.
i tried this command
start javaw -jar jogurtLaunch.jar
and i tried rightclick and 'open with' and using the java12 exe (both java.exe and javaw.exe), but nothing happens except for the windows cmd prompt popping up for a few milliseconds in case of the exe and a jvm error ('Error: A JNI error has occurred, please check your installation and try again') popping up in case of the command.
Also i'd prefer a solution that is usable on all computers and not just for java12 development pcs.
Is there a way or do i have to code it in java8?
I have tried the following:
in terminal it works
In Intellij it works
I have tried to launch it with javaw.exe but nothing changes
Are there any other options?
This looks like an OS problem that an application building one -- because you said that it works in your IDE and terminal.
Make sure that you installed Java properly in your machine.
In Windows/MacOs, after installing Java, the *.jar files are automatically associated with the java -jar command and makes it runnable via double-click.
In linux, this varies on the flavour or DE you are using. But there's probably a utility in your OS to open *.jar files using java -jar command.
Okay so I have been coding a game for a while now and I am hoping to release its alpha just one problem. I don't know how to export it and run it. Please note that all my code works fine. So when I export it I export it as a Runnable jar file once I do so I set it and have tried both exporting it as .jar and .exe. Once I exported it I tested it by clicking the resulting file but it doesn't open the application but rather it opens it in eclipse encoded. Please help I may just be an idiot.
you have to try to launch it with:
java -jar yourrunnable.jar
If you plan to run on windows and you want a .exe file, try to check this SO question: How can I convert my Java program to an .exe file?
or if you want to target a mac, you can have a check here:
http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
Basically any platform you target you have some customization in order to achieve a seamless run. Anyway the most cross platform solution is the Java -jar way.
I had the same problem with .jar files not opening on a double click. It turned out that I had two versions of Java installed (Java 6 and 7). Uninstalling Java 6 from Control Panel-> Uninstall a Program was what finally allowed .jar files to open on a double click without using the command window.
What is listed in right-click-> Open With ? Is some other program listed as the default program ? Is a Java Runtime listed ? If a Java Runtime is listed, you can open with it, and make it the default program to run with.
Right Click -> Properties -> Change -> C:\Program Files\Java\jre7\bin\javaw.exe
For Java 8 use below
java.exe -jar myFile.jar
Why does command prompt open and close immediately when i open netbeans ide ?Although i do not want to use the command prompt, strangely it opens and closes by itself each time i open netbeans ide, and then opens the application itself and works just fine. I am curious to know why this happens. I've tried searching and asking some but could get an answer. Thanks in advance.
On which platform? It sounds like it's started via a shell script launcher (.sh / .cmd file), so the shell ("command prompt") is launched to run the launcher, and then the launcher script starts Netbeans...
Assuming you are using Windows:
NetBeans.exe is a 32bit application, but if you are using a 64bit JDK, the 32bit exe closes itself (because a 32bit executable cannot load a 64bit JVM) and then launches NetBeans64.exe - I think this closing and re-starting is the reason for the command line window to show up briefly.
If you start NetBeans64.exe directly, then this doesn't happen.
I had the same issue with Netbeans 8.0.2 on windows where commands were opening separate cmd windows.
Resolved this way:
Right-click on the shortcut for Netbeans or the exe (Launcher).
Click Run as administrator
It worked for me.
You can try to right click on the icon and go to its properties. Copy the value in the Target field. Paste it into a command prompt and run it manually. This time the command prompt should not close and you can see for yourself what the error is.
I am new to Java.
Basically, I developed a java projects which contains multiple Java packages inside Eclipse. The project runs OK on my desktop with a redhat Linux installed. However, I need to run it on a more powerful Linux server (redhat enterprise Linux) which does not have X11 installed. Therefore, it is impossible to run Eclipse on that server.
Is it possible to do that? If so, how can I move the entire project to that server including the input and output folders?
Thanks
In Eclipse use the "Export Runnable Jar" option. Highlight your project then click file->Export, choose Java, choose Runnable Jar file. Otherwise you can also use the javac compiler to compile your project and run it with the java command and your main class.
You will need to install the JRE on the machine you want to run it on. This can be done with the following command:
yum install java-1.6.0-openjdk*
Once you have java then it is simply a matter of executing your application. I would recommend using eclipse to compile your project to a jar and use the following command to execute it:
java -jar *JarFileName*.jar
Running Java is nothing to do with Eclipse . You can run your java program in linux machine by opening terminal .
Step1;- Set your JAVA_HOME in your bash profile .
Step2:- open terminal , go to the folder or package where your main program is present.
Step 3:- compile it using javac -cp lib.jar Filename.java
Step 4:- After compilation class file will be available , run it using java filename.java
Usually IDE like eclipse is for development not for running the application , but Linux version of eclipse is also available
http://eclipse.org/downloads/?osType=linux