Open console when i run java jar file
greetings all
i have a java program that i execute through JCreater. i want if i make its JAR file then its console should be open so that i could see thats printing when i use "System.out.println". is there anyway? right now when i double click my JAR file then nothing is displayed. how can i make that happen?
thx flounder
you see i need to see whats printing through my System.out.println() command. I am working on JCreater at the moment. when i execute my program an output window is opened, it displays whatever i have written in System.out.println. now i want to make an executable JAR of my program and also want to see my output window. is there any way to do that?
Similar Messages
-
Help with running java .jar file
Hi I just installed java with
# pacman -S jre
and when i try to run
java -jar file.jar
it says command not found. so what do i need to install to be able to run java .jar files through the CLI?do, what vintendo says. because it cant find the java in the default paths.
-
Hello,
I got a java jar file which contains folders with class file. When I double click on the jar file, it gave a error
Exception in thread "main" java.lang.NoClassDefFoundError
How can I run this jar file?
Thanks,
CRHello,
I got a java jar file which contains folders with
class file. When I double click on the jar file, it
gave a error
Exception in thread "main"
java.lang.NoClassDefFoundError
How can I run this jar file?
Thanks,
CR... and assuming that Jar contains a manifest file, what does it look like? I would guess that the Main-Class entry is incorrect, or that the Jar has external dependencies to other jars not listed properly in the Class-Path entry. -
Images are not coming out when application running through jar file.
I have written an application program using j2sdk1.4.1 that needs your help.
My application folder's contents.....................
C:\Examination\Examination.class <-----This is the main class and application's entry point.
C:\Examination\ExamBox.class
C:\Examination\PaperSetterBox.class
C:\Examination\pspBox.class
C:\Examination\epBox.class
C:\Examination\TimerBox.class
C:\Examination\ReportCardBox.class
C:\Examination\HelpBox.class
C:\Examination\AboutBox.class
C:\Examination\Images\(some jpg & gif files)
C:\Examination\Sounds\(some au files)
Compilation Report: There was no error.
Execution Report : Was working properly using the command:- java Examination
Now, I created a jar file for my application in the following steps.................................
STEP-1: Firstly, I created a text file(mainclassInfo.txt) that contains
the line:-- Main-Class: Examination
This line would be automatically added to the default manifest file when I would include the name of that text file with the command to create the jar file.
Location of the text file I created: C:\mainClassInfo.txt
STEP-2: Then I went to C:\Examination and executed the following command(by using 'Command prompt'):--------------------------------------------------------------------
jar cmf C:\mainClassInfo.txt Examination.jar Examination.class ExamBox.class PaperSetterBox.class pspBox.class epBox.class TimerBox.class ReportCardBox.class HelpBox.class AboutBox.class Images Sounds
Finally, I got the jar file:- Examination.jar
Double clicking on it application ran as it was expected.
Then, I thought, that as all the files & folders the application needed to run properly were packaged in the jar file; I should delete all the contents of the folder 'Examination', so that no one could see or use anything of the resources easily. I did that.
So, then it became only:-- C:\Examination\Examination.jar
Thereafter, I tried to run the application again and there a problem occurred! The application was running, but the images, those were to be used and shown by the application were missing somehow!!
Moreover, when I kept a copy of those 2 folders('Images' and 'Sounds') into the C:\Examination and ran the application again all the images came out normally!
I just can't understand why it's happening so mysterious?
I don't want to leave anything of the resources in an open place; I mean, outside of the jar file. The images should be used and shown by the application.
Help me please!double post http://forum.java.sun.com/thread.jspa?threadID=582311
-
Cannot run "java -jar javapetstore-2.0-ea5-installer.jar "!
My java version is:
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode, sharing)
When I run "java -jar javapetstore-2.0-ea5-installer.jar"
I get errors:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Exception in thread "main" java.lang.NullPointerException
at javax.swing.plaf.synth.SynthLookAndFeel$AATextListener.propertyChange(SynthLookAndFeel.java:793)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:347)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
at java.awt.Toolkit.setDesktopProperty(Toolkit.java:1784)
at sun.awt.SunToolkit.fireDesktopFontPropertyChanges(SunToolkit.java:1714)
at sun.awt.SunToolkit.setAAFontSettingsCondition(SunToolkit.java:1759)
at sun.swing.SwingUtilities2$AATextInfo.getAATextInfo(SwingUtilities2.java:119)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initComponentDefaults(GTKLookAndFeel.java:1258)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.getDefaults(GTKLookAndFeel.java:294)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:537)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:581)
at org.jvnet.poormans_installer.Main.setUILookAndFeel(Main.java:88)
at org.jvnet.poormans_installer.Main.main(Main.java:49)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.initSystemColorDefaults(GTKLookAndFeel.java:1267)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.loadStyles(GTKLookAndFeel.java:1509)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel.access$000(GTKLookAndFeel.java:37)
at com.sun.java.swing.plaf.gtk.GTKLookAndFeel$WeakPCL$1.run(GTKLookAndFeel.java:1449)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
My OS is CentOS5.1 final.have u set the path to java 1.4.1 ?
if u set the path ,,, the there will no problem. -
Closing Console window while running Java application from Batch file
Hi all,
I have made a small application using Java swings,now i have made a jar file of my application and calling this jar file through batch file,when user clicks on that batch file it runs "java -jar applicationname.jar" command,but problem is that when i run that file from batch file it opens Dos console window at baclk of the screen which looks weird for a desktop application,i dnt want that Dos console window visible at the backend while my application is running,i have searched regarding this on google but found nothing usefull,if anybody can please help regarding that it will be a great releif for me,i have been stuck on this problem from last two days.
Thanks.
Simerwarnerja wrote:
georgemc wrote:
warnerja wrote:
start java -jar applicationname.jar
That'll pop up another consoleI'm under the impression that the console window he is seeing is the one which cmd.exe opens when it is executing the batch file. And that batch file won't return until the java process has completed because he didn't start it in the background to let the batch file continue and terminate.
So I don't think just simply substituting java with javaw will do much good either. Still think he needs a "start" command in that batch file.
So now he can try:
start java -jar ...
or
start javaw -jar ...Fair point -
[SOLVED]Java error running a .jar file
Hi. I'm running Arch 64 and I keep getting this error when trying to run
java -jar TwinkEdit-0.6.9.jar (from twinkle.sourceforge.net -- a flashcard program for palm. This .jar is the desktop editor for the flashcards. It's worked before on Linux ... but that was almost 2 years ago.)
Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
at java.util.Vector.firstElement(Vector.java:442)
at org.ekimd.twinkedit.TwinkUI.getJapFont(TwinkUI.java:979)
at org.ekimd.twinkedit.TwinkUI$DynamicView.<init>(TwinkUI.java:589)
at org.ekimd.twinkedit.TwinkUI.getDynamicView(TwinkUI.java:815)
at org.ekimd.twinkedit.TwinkUI.access$1300(TwinkUI.java:88)
at org.ekimd.twinkedit.TwinkUI$NewAction.actionPerformed(TwinkUI.java:1101)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
It happens in both 32 bit (arch32 chroot) and 64 bit jre's exactly the same.
java -version gives:
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)
(It also doesn't work on Windows, either .... I think it must be a Java version compatibility problem ??)
Any ideas?
Thanks,
Scott
Last edited by firecat53 (2008-09-27 14:07:04)I gave it a try and got the same error. Then I started looking at the code:
When you create a new file, the program starts looking for a font which supports japanes (don't ask me why). If it doesn't find any it throws the error you posted above. I was able to create a new file after I installed ttf-bitstream-cyberbit from AUR (first font supporting japanese I could find).
You should contact the author and submit a bug report. Even if the program really needs japanese fonts, which I doubt, failing like this is just bad.
Last edited by Garns (2008-09-27 13:26:05) -
Running a jar file from java code
Hi!
Im trying to run a jar file from my code.
I've tried Classloader, but that doesnt work because it doesnt find the images (also embedded in the 2nd jar file).
WHat I would like to do is actually RUN the 2nd jar file from the first jar file. There must be a way to do this right?
any ideas?ok, I found some wonderful code (see below) that will try to start the jar. But it doesn't. What it does is produce the following error when my application runs...
So it's not finding the images in the jar file that I am trying to run? Strange. I checked the URL that sending, but it seems ok....
I think I will check the url again to make sure......
any ideas?
Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(Unknown Source)
at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
at sun.awt.image.ImageFetcher.run(Unknown Source)
the code....
/* From http://java.sun.com/docs/books/tutorial/index.html */
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.jar.Attributes;
* Runs a jar application from any url. Usage is 'java JarRunner url [args..]'
* where url is the url of the jar file and args is optional arguments to be
* passed to the application's main method.
public class JarRunner {
public static void main(String[] args) {
URL url = null;
try {
url = new URL(args[0]);//"VideoTagger.jar");
} catch (MalformedURLException e) {
System.out.println("Invalid URL: ");
// Create the class loader for the application jar file
JarClassLoader cl = new JarClassLoader(url);
// Get the application's main class name
String name = null;
try {
name = cl.getMainClassName();
} catch (IOException e) {
System.err.println("I/O error while loading JAR file:");
e.printStackTrace();
System.exit(1);
if (name == null) {
fatal("Specified jar file does not contain a 'Main-Class'"
+ " manifest attribute");
// Get arguments for the application
String[] newArgs = new String[args.length - 1];
System.arraycopy(args, 1, newArgs, 0, newArgs.length);
// Invoke application's main class
try {
cl.invokeClass(name, newArgs);
} catch (ClassNotFoundException e) {
fatal("Class not found: " + name);
} catch (NoSuchMethodException e) {
fatal("Class does not define a 'main' method: " + name);
} catch (InvocationTargetException e) {
e.getTargetException().printStackTrace();
System.exit(1);
private static void fatal(String s) {
System.err.println(s);
System.exit(1);
* A class loader for loading jar files, both local and remote.
class JarClassLoader extends URLClassLoader {
private URL url;
* Creates a new JarClassLoader for the specified url.
* @param url
* the url of the jar file
public JarClassLoader(URL url) {
super(new URL[] { url });
this.url = url;
* Returns the name of the jar file main class, or null if no "Main-Class"
* manifest attributes was defined.
public String getMainClassName() throws IOException {
URL u = new URL("jar", "", url + "!/");
JarURLConnection uc = (JarURLConnection) u.openConnection();
Attributes attr = uc.getMainAttributes();
return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;
* Invokes the application in this jar file given the name of the main class
* and an array of arguments. The class must define a static method "main"
* which takes an array of String arguemtns and is of return type "void".
* @param name
* the name of the main class
* @param args
* the arguments for the application
* @exception ClassNotFoundException
* if the specified class could not be found
* @exception NoSuchMethodException
* if the specified class does not contain a "main" method
* @exception InvocationTargetException
* if the application raised an exception
public void invokeClass(String name, String[] args)
throws ClassNotFoundException, NoSuchMethodException,
InvocationTargetException {
Class c = loadClass(name);
Method m = c.getMethod("main", new Class[] { args.getClass() });
m.setAccessible(true);
int mods = m.getModifiers();
if (m.getReturnType() != void.class || !Modifier.isStatic(mods)
|| !Modifier.isPublic(mods)) {
throw new NoSuchMethodException("main");
try {
m.invoke(null, new Object[] { args });
} catch (IllegalAccessException e) {
// This should not happen, as we have disabled access checks
} -
Getting error when running the jar file..
Hi All,
I am new to executing jar file..Actually i have one class which contains the following code.
import com.documentum.fc.client.DfClient;
import com.documentum.fc.client.IDfClient;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.common.DfLoginInfo;
import com.documentum.fc.common.IDfLoginInfo;
import com.documentum.fc.common.DfException;
import com.fidelity.ftg.ereviewg2.migration.util.MigrationResource;
* This class is used for creating docbase connection
* *@type* DocbaseConnection
* *@author* a405304
* *@see*
public *class *DocbaseConnection {
//public static ResourceBundle resource;
IDfSessionManager sMgr = *null*;
IDfSession session = *null*;
String docbaseName;
*private* *static* DocbaseConnection +docbaseCon+;
* Constructor for DocbaseConnection
* *@throws* DfException
* *@throws* Exception
*private* DocbaseConnection()*throws* DfException, Exception{
//ResourceBundle bundle = ResourceBundle.getBundle(Constants.RESOURCE_PATH,Locale.getDefault());
MigrationResource bundle = MigrationResource.+getBundle+();
String userId = bundle.getString("DOCBASE_USERID");
String password = bundle.getString("DOCBASE_PASSWORD");
docbaseName = bundle.getString("DOCBASE_NAME");
IDfClient client = DfClient.+getLocalClient+();
sMgr = client.newSessionManager();
IDfLoginInfo loginInfo = *new* DfLoginInfo();
loginInfo.setUser( userId );
loginInfo.setPassword( password );
loginInfo.setDomain("");
sMgr.setIdentity( docbaseName, loginInfo );
session= sMgr.getSession( docbaseName );
System.+out+.println("# Connected to Docbase: "+session);
}Now i create the jar file whose name is docbaseconnection.jar
Now when i am running this jar file by using the following command then i am getting the following error..
C:\JAR_FILES>java -jar docbaseconnection.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/documentum/fc/client/DfQuery
For running this docbaseconnection.jar file i need the following thing in classpath...
C:\Program Files\Documentum\dctm.jar;C:\Program Files\Documentum\Shared\dfc.jar;C:\Program Files\Documentum\Shared\log4j.jar
I already add this jar files in the classpath of environment variables..Then also i am getting the same error..
Kindly help me...........Well, let´s supose your manifest is defined as I did in my previous post. So, your directory base should be something like:
C:\dir
docbaseconnection.jar
dctm.jar
dfc.jar
anotherlibraries.jar
But, let´s supose you want something like
C:\dir
docbaseconnection.jar
lib (folder, which contains dctm.jar, dfc.jar, etc)
Then you should change the class-path of your manifest to
Class-Path: ./lib/dctm.jar ./lib/dfc.jar
That´s what I meant -
Why will my java.jar file not open
Why will my java.jar file not open
This is the iPod touch forum. Do you have a question concerning an iPod touch? The iPod touch does not run Java.
If you have a new Mac you have to download the Java program to run Java on a Mac. It no longer comes with the iOS. -
Opening a java jar file through a labview program
Hello,
I need to open a java jar file in labview........this jar file is a GUI with multiple frames and has buttons on each frame help navigate through between frames....i just require the program to open it and close it based on some signals so then i won't have to do it manuallyLabVIEW doesn't have any control over what happens in a system exec, as you give the control to the system. You can, however, check the process list through .NET commands and kill the process (You should be able to stop it through "taskkill /F /im java.exe"). Not the prettiest solution, but should work.
/Y
LabVIEW 8.2 - 2014
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
G# - Free award winning reference based OOP for LV -
Why does my Jar Launcher fail when I try to run a .jar file?
Whenever I try to run a .jar file since I updated to mavericks the Jar Launcher will start running java and then crash. I've reinstalled java and checked all my prefrences, but I can't figure out why this is happening.
I downloaded the latest Java from java.com (they have the latest version) and it worked for me
-
Run applications ( .jar files) by bash on linux
On linux:
I have a swing application and its jar file. I created an executable file using bash script to run the jar file
#!/bin/bash
java -jar myapp.jar
this runs in console normally but when i clicked the executable file, the application runs too but immediately closes. I think the problem is that this can't recognize the swing-layout.jar (swing library) so that the swing components (JFrame,Jbutton) cannot be showed!
There must be a way for the executable file to recognize the libraries (swing, layouts) for the application by using bash script ?There can be number of reasons for that. I suggest you following way:
1. Modify your script in following way:
#!/bin/bash
java -jar myapp.jar 2>/tmp/log.err 1>/tmp/log.out
After unsuccesful execution check content of /tmp/log.* files and see details of the error.
Often such errors are caused by environment. May be you just don have java in your PATH .. May
be DISPLAY is not set .. I don't know.
To workaround env issue you need to dump environmentin from console:
declare -x >env.sh
After that include update your .sh script in following way and see the difference:
#!/bin/bash
. env.sh
java -jar myapp.jar 2>/tmp/log.err 1>/tmp/log.out -
OutOfMemory Exception while running a JAR file
Hi,
I am working with Java 1.5 and using Eclipse to build a GUI. My application has intensive image loading involved so I set -Xmx inside Eclipse when running the application in debug mode.
However, once a JAR file is exported, I do not know how to specify the heap size required to run the program. Is there a way to ...
1. embed the heap size info inside the JAR file?
2. specify a heap size when running the JAR file?
Thanks in advance.Heap size is specified by the -Xmx option on the java command. See the java command documentation.
-
Unable to Run a .jar file in pjava
I have installed pjava (for StrongArm) on to my iPAQ Pocket PC H3660.
Then I created a simple application using JBuilder and created a *.jar file of the classes. I have used the awt classes to build the interface. I am using JDK version 1.3.0.
When I deploy it into my Pocket PC and run the jar file, the compiler loads up and I get the error message "Cannot find class : packagename.classname".
I have checked the jar file contents in JBuilder and the class files are all in there.
Could anyone help me on this? Thanks!If you are compiling with JDK1.3 (or any compiler > java 1.1.8), you have to use the parameter "-target 1.1" to make sure the class files will be loaded by a 1.1 JVM. Jeode doesn't seem to care about this setting, but when we switched to Creme the problem arose.
-Eric
Maybe you are looking for
-
Scheduling of Automatic Clearing (FPMA) of FI-CA Open Items in background
Hi, I was trying to schedule daily runs of Automatic Clearing (FPMA) in background using SM36. I understand that running Automatic Clearing of Open Items on a periodic basis is a usual practice in the Utilities industry. However, SM36 is throwing an
-
I made a form for retrieving a password in case the person forgot their password, and what I wanted to know is there a way to highlight the form field they got wrong so they know exactly which to correct? One more thing can you guys look at my code a
-
Hi Guys, While creating a customer I am not able to specify the reconciliation account, system isn't allowing me to enter any input in FD01 - company code data screen but when I double click its taking me to the G/L account screen of AR. I have also
-
SF300 Daisy Chain VLAN Question
OK, this is a complicated setup, and myself and my fellow IT staff have been beating our heads on a wall trying to get this to work, at this point we do not even know if we have this configured right, so any input on this would be most appreciated. W
-
Possible to retrieve an '09 blog published on iWeb/MobileMe?
Argh. I published my family's travel blog a few years back using MobileMe (web.me.com/shwang), and stupidly forgot about it during the MobileMe/iCloud transition. Is there any way to retrieve the blog's contents, with or without comments?