Call a jar in the command
Hi, I generated a jar out of my java project, and I want to invoke it in the command.
The problems are:
1. The class I want to turn to is in a package.
2. I want to invoke specific method in it
My class that contain the method to invoke is: myClass
The method I want to invoke inside myClass :myMethod
The jar file name is : myJar
The package name is: myPackage.
Should I write in the command:
java -jar myJar.myPackage.myClass.myMethod ???
Thanks.
Go through [_this tutorial_|http://java.sun.com/docs/books/tutorial/deployment/jar/index.html] and learn about the jar manifest.
Or include the jar in the -cp (classpath) flag and use a driver class with a main(...) method that loads 'myClass' (should be MyClass, class names should always start with a capital letter) and invokes the method.
db
Similar Messages
-
Running a jar from the command line
I am trying to run a Jar from the command line. I have a number of classes in a package called "trainnn".
I put all the classes into a jar
jar cvf name.jar trainnn\*.classI then creat a file called mainClass.txt with the line (with a blank return line after it, where QueryMatch has the main). This file was placed in the same directory as the package and the jar file
Main-Class: QueryMatch
then
jar cmf mainClass.txt network.jar G:/TrainNN/src/trainnn/QueryMatch.classthis worked fine.....but it is from here I have problems when I try run the jar
java -jar network.jarbut get this error.
Exception in thread "main" java.lang.NoClassDefFoundError: QueryMatch
I cant figure out this error, I have tried specifying the exact path in the mainClass.txt file but that didnt work.
Any ideas
Thanks in advance.Hi,
To start a java app in the command line with "java -jar yourJarFile.jar", the jar needs to have a mainfest file "MANIFEST.MF" in a folder called "META-INF". The manifest file would have to contain the name of your starting class, e.g. it could look like thisManifest-Version: 1.0
Main-Class: com.yourCompany.yourProject.YourClass Hope that helps. Cheers, HJK -
Calling r25con32.exe from the command prompt
how to call r25con32.exe from the run prompt.
Duplicate:
Calling r25con32.exe from the command prompt
:) -
Jar run from command prompt?
Hi !
How do I run my Jar from the command prompt window?
my jar's name is " javaproject 7"
Thanks!Java application launcher documentation:
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/java.html -
trying to login to software program known as hamspher (vip simulated ham radio, it downloaded the program but it will not allow me to login with call sign and pin. it has to be opened with what they call a jar file. how do i do this?
This is compatible with Mac? Especially Snow Leopard (if that is what you'e running)?
Have you considered posting your question in their forums?
Here is some information re. the jar file:
http://ostermiller.org/opening_jar_files.html -
Hi ,
I have an EJB A which is already deployed when the server starts. A second ejb
B is deployed at a later time.
EJB A calls methods in EJB B. I use reflection in EJB A to call methods in EJB
B.
I get a NoSuchMethodException when I call the create method in the Home object
of EJB B. If I add the ejb jar file to the classpath before the server starts
then it is able to resolve the method.
The problem is the EJBs which are called from EJB A is not known before the server
is started. New EJBs can be deployed at runtime and EJB A should be able call
the methods in newly deployed EJB's.
I also use the URLClassLoader to load all the classes in the jar file of the newly
deployed EJB in EJB A and it still gives a NoSuchMethodException because it cannot
resolve the stub class.
My error log is shown below.
This is an urgent issue.
Thanks
SampleConnector::testEJBService called
In Key : P1 Value : Input2
In Key : P3 Value : Input1
In Key : P2 Value : SomeConst
Loaded Class = com.bizwave.samples.rejb.SampleRemote
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_EOImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_HomeImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_Impl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteHome
java.lang.NoSuchMethodException
at java.lang.Class.getMethod0(Native Method)
at java.lang.Class.getDeclaredMethod(Class.java:1151)
at com.bizwave.samples.ejb.SampleConnectorEJB.testEJBService(SampleCon
ctorEJB.java:181)
at com.bizwave.samples.ejb.SampleConnectorEJB_be5y1v_EOImpl.testEJBSer
ce(SampleConnectorEJB_be5y1v_EOImpl.java:98)
at java.lang.reflect.Method.invoke(Native Method)
at com.bizwave.fc.utils.ClassUtils.invokeEJBMethod(ClassUtils.java:109
at com.bizwave.infra.fjet.engine.EJBServiceStepMgr.executeService(EJBS
viceStepMgr.java:91)Hi,
I am attaching a test case. This test case actually demonstrates a security bug.
Unzip the file and modify the StartWeblogic.cmd in domainA to not refer to the
SampleRemoteEJB.jar in the classpath. If u run the test client under the client
dir u will see a NoSuchMethodException.
The reason is it is not able to load the dynamically generated stub file.
Initially I had the getMethod and it didn't work. You might have to modify the
files to suit ur env. The easier way is to run th edomain wizard and create 2
domains. Run the servers in development mode and place the jars under the applications
dir
Thanks
Rajesh Mirchandani <[email protected]> wrote:
Do you have any old EJB classes in your classpath? Did you recompile
your EJBs if you
upgraded from a old release or a Service pack?
Bob Lee wrote:
Hmmmm. That's an interesting problem.
Why is it giving you a NoSuchMethodException instead of a
ClassNotFoundException?
Can you post the code from SampleConctorEJB.java, line 181?
Try changing your call to getDeclaredMethod() to getMethod().
getDeclaredMethod() searches only the class you called it on, whereas
getMethod() traverses to the superclasses and interfaces. You onlyneed
getDeclaredMethod() when you're accessing a nonpublic method.
Not sure if this will help, but it's worth a shot.
Bob
Vasu wrote:
Hi ,
I have an EJB A which is already deployed when the server starts.
A second ejb
B is deployed at a later time.
EJB A calls methods in EJB B. I use reflection in EJB A to call methodsin EJB
B.
I get a NoSuchMethodException when I call the create method in theHome object
of EJB B. If I add the ejb jar file to the classpath before the serverstarts
then it is able to resolve the method.
The problem is the EJBs which are called from EJB A is not knownbefore the server
is started. New EJBs can be deployed at runtime and EJB A shouldbe able call
the methods in newly deployed EJB's.
I also use the URLClassLoader to load all the classes in the jarfile of the newly
deployed EJB in EJB A and it still gives a NoSuchMethodExceptionbecause it cannot
resolve the stub class.
My error log is shown below.
This is an urgent issue.
Thanks
SampleConnector::testEJBService called
In Key : P1 Value : Input2
In Key : P3 Value : Input1
In Key : P2 Value : SomeConst
Loaded Class = com.bizwave.samples.rejb.SampleRemote
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_EOImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_HomeImpl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteEJB_svq1df_Impl
Loaded Class = com.bizwave.samples.rejb.SampleRemoteHome
java.lang.NoSuchMethodException
at java.lang.Class.getMethod0(Native Method)
at java.lang.Class.getDeclaredMethod(Class.java:1151)
at com.bizwave.samples.ejb.SampleConnectorEJB.testEJBService(SampleCon
ctorEJB.java:181)
at com.bizwave.samples.ejb.SampleConnectorEJB_be5y1v_EOImpl.testEJBSer
ce(SampleConnectorEJB_be5y1v_EOImpl.java:98)
at java.lang.reflect.Method.invoke(Native Method)
at com.bizwave.fc.utils.ClassUtils.invokeEJBMethod(ClassUtils.java:109
at com.bizwave.infra.fjet.engine.EJBServiceStepMgr.executeService(EJBS
viceStepMgr.java:91)
Rajesh Mirchandani
Developer Relations Engineer
BEA Support
[user_projects.zip] -
How to call a jar file for the dynamic menu
hi ,
I am using JDEV 11.1.2.2.0 version.
My problem is this,
when dynamic tree populate using java bean class(data come from the table)
how can we call a jar files(seperate projects jars) to each link of the tree.
plz help...
-Harsh-Hi,
projects are a design time functionality. So what is the use case? I it is a Java object stored in the JAR file then you would configure this JAR file in the ViewController project library section (project properties)
Frank -
How can we call a jar files(seperate projects jars) to each link of the tre
how can we call a jar OR WAR files(seperate projects jars OR War) to each link of the tree.
i want have home page that have this menu
========================
-- Sale
--- Customer
--- Reader
-- Energy
--- Calc
-- Service
--- Chnage Name
--- Change Code
=======================
For example
--- Change Name
---- Page Reister
---- Page Confirm
---- Page Anoc
---- Page Save
======================
i want user to access to every page From Each Case(Change Name) .
i create for change name one project in my fushion web app and for other case
How to I Can Call Page register From change name in Menu of The home page ????
Edited by: user13151366 on Feb 4, 2013 4:44 AM -
Call *.jar inside the trigger (MS SQL)
Hi!
I'm just looking around google and can't find any good news.. The problem is: how to call *.jar inside the trigger. Trigger is stored in M$ Server.
Tnx, if any response! ;)What?
-
Running jar files from the command line
I have always felt it would be useful to run a jar file from th command line in EXACTLY the same way as an EXE. On some systems, typing MYAPP.JAR will run the app, but doesn't output and command line data, so it only works for GUI apps. I've come up with a tiny C program that runs java -jar xxxx.jar for you.
#include <stdio.h>
#include <string.h>
#include <process.h>
void main(int argc,char *argv[])
char cmd[1024];
strcpy(cmd,"java -jar ");
strcat(cmd,argv[0]);
strcat(cmd,".jar");
for(int arg=1;arg<argc;arg++)
strcat(cmd," ");
strcat(cmd,argv[arg]);
system(cmd);
}Simply compile this to an exe, rename the exe to the name of your jar file and put it in the same directory. Then just type 'MyJarFile' (no jar extension) and it should run. It passes all command live args as well. Comments ?Here's a better version. The JAR and the EXE can be anywhere in the PATH:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <process.h>
void main(int argc,char *argv[])
char jar[1024];
char cmd[1024];
strcpy(cmd,argv[0]);
strcat(cmd,".jar");
_searchenv(cmd,"PATH",jar);
strcpy(cmd,"java -jar ");
strcat(cmd,jar);
for(int arg=1;arg<argc;arg++)
strcat(cmd," ");
strcat(cmd,argv[arg]);
system(cmd);
} -
What is the command to check if there are any active calls before restarting the voice router?
what is the command to check if there are any active calls before restarting the voice router? thanks
Hi.
I can suggest show call active voice or show voice call status or show sip-ua call brief in case of SIP TSP.
HTH
Regards.
Carlo -
Run a jar on Windows without the command window
I would like to run a jar and close the command window after starting up. Is this possible please.
I would like to run a jar and close the command window after starting up. Is this possible please.why do you want to do that? jar files are executable files so when you double click it, it will execute without having to run it from the command prompt. So, you don't have to even open the cmd prompt to run .jar files.
-
Jar file runs from the command line, but not when I double click it
Hello, I'm running windows xp. I've created an executable jar file and it runs fine from the command line when I type;
java -jar wizard.jar
but, when I double click it . . . nothing.
Any ideas?nothing ? that's weird, windows XP should prompt you to select the program you want to use in order to open Jar files (and give you this silly piece of advice to search the web for the appropriate program)
you might want to check what program (if any) got associated with .jar extensions :
in Windows Explorer : Tools => Folder Options => File Types
hth -
Distrubuting jar (the command)
I am currently developing an installer for my team and it would be really useful to jar various things together at install time. (Dynamically provide a .jar with the functionality users want.)
Is it ok to have the jar program in my installer? WIll that violate Sun's licensing? The installer will not leave the jar executable on the customer's system.
Thank you
(Sorry if there is a better forum for this question.)Your best bet would be to get a lawyer, and give him/her the EULA for the JDK.
.jars are just zip files, so you could either just use any zip tool, or if the installer is in Java, then the java.util.zip and java.util.jar packages.
Or distribute as multiply zip files, then have the installer build the -classpath argument to the javaw link/bat/sh/�? -
Can't run JavaFX app as a jar file from command line
I'm trying to build a JavaFX app from scratch (that is, by including the jar file from the JavaFX SDK rather than by using the special JavaFX project type from NetBeans). It runs fine in NetBeans. However, when I try to launch it as a jar file from the command line (using "java -jar dist\TestApp") I get the following. Has anybody seen this before, and if so how can I fix it?:
*** Fallback to Prism SW pipeline
Exception in thread "main" java.lang.RuntimeException: java.lang.UnsatisfiedLink
Error: Can't load library: C:\dev\TestApp\dist\bin\mat.dll
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
289)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:68)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherIm
pl.java:145)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:
27)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:97)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: C:\dev\RedactionT
oolPrototype\RedactionToolPrototype.Core\dist\bin\mat.dll
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.sun.glass.utils.NativeLibLoader.loadLibraryFullPath(NativeLibLoad
er.java:155)
at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoad
er.java:85)
at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:
30)
at com.sun.glass.ui.Application$1.run(Application.java:28)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.glass.ui.Application.loadNativeLibrary(Application.java:26)
at com.sun.glass.ui.win.WinApplication.<clinit>(WinApplication.java:33)
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
Factory.java:20)
at com.sun.glass.ui.win.WinPlatformFactory.createApplication(WinPlatform
Factory.java:17)
at com.sun.glass.ui.Application.Run(Application.java:51)
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:
279)
... 5 moreUnsatisfied link means that Java is trying to access a native library, but it cannot be found. As to why this error is being thrown, here is my guess:
If you open up one of the sample jars with a zip viewer, you will see that the Manifest file has the following entries:
>
Manifest-Version: 1.0
JavaFX-Version: 2.0
implementation-vendor: Oracle
implementation-title: BrickBreaker
implementation-version: 1.0
JavaFX-Application-Class: brickbreaker.Main
Created-By: JavaFX Packager
Main-Class: com/javafx/main/Main
>
In other words, a JavaFX project works a bit differently than a normal Java project. com/javafx/main/Main is used as the Main class and your "Main" class is called later.
If you are trying to build this from a normal Java project, then com/javafx/main/Main will not be created and it will call your Main class right away. Thus, whatever setup is needed to run JavaFX will not occur.
Maybe you are looking for
-
Cell Definition in Query Designer
Hi,, Can anyone will tell me the real time use of cell definition option in query designer. Thanks and Regards. Anjali
-
Failover Cluster, Hyper-V, Virtualised PDC and Time Sync
Hi, I wonder if anyone can clear something up for me. We have two hosts running failover cluster and hyper-v. On these hosts we two Virtual DCs (one of which is our PDC) as well as a number of member servers. In Hyper-V integration services we have s
-
I need help with the settings, General to update my itunes, but there is no word saying software, for me to start the process. Also, need help syncing my music to my Ipad. help?
-
Conversion of large RAW images broken in iOS 7?
Under iOS 6, I was able to use the camera connection kit to import 36 MP RAW (.NEF) images from my Nikon D800 to my iPad 2, and then open them in Snapseed for quick edits while on the road. Along came iOS 7 and Snapseed crashes trying to open these
-
How to get rid of an extra space between news items in news module
My home page is www.turbocam.com. Notice on the left side that there is an extra space between news item 1 and 2. Between news item 2 and 3 the spacing is normal. I haven't touched the template. Any thoughts as to why this is occuring? The module is