How to run class files in a jar independently.

Hello all
I have a java file which use an API.jar file which is an API file of some other application of mine.This file form a sought of client for that application.Now i want to run this file from command line which is giving NoClassDefFoundError exception.This exception is because of the dependency over API.jar.I dont want to pack this single file into a jar and then run that jar since it only makes a simple task complicated and makes a simple class look like a big application.Can anybody tell me the solution to it?
Regards,
Mansi

MansiSachar wrote:
I am working on WindowsXP and the command u just sent is again giving the same exception.The exception is :
Exception in thread "main" java.lang.NoClassDefFoundError: ûcp
Caused by: java.lang.ClassNotFoundException: ûcp
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
I think the problem can also be the placement of the dependant jars.do i need to keep them in "bin" folder?I am assuming that in the error message, it says "-cp" not "ûcp" Can you confirm that you entered the command as posted? Because it looks like java.exe sees the -cp as the class to execute instead of the classpath option.
Try using -classpath instead of -cp. What version of java are you using? (java -version should give you the version).
If the jars are in the current directory, the placement of the jar files is correct.

Similar Messages

  • How to run .class file and .jar file in jdev9i

    I want to run .class file and .jar file in jdev9i,what should I do?
    Also,I want to generate .class file and .jar file in jdev9i,what should i do?

    Add the .class file containing the public static void main(...) method to the project by clicking on the + toolbar button in the navigator, open the project properties and properly set the additional classpath then right click on the .class in the navigator and say run. It should work, I've just tried it.
    Doesn't work for a .jar yet, in JDeveloper 9.0.3 it works both for .class and .jar
    Michel

  • How to get .class files from a JAR at runtime

    Hi. I wrote a program that load the classes it find in the "prog/components" directory. It enables me to add new components without messing with the code of the main program. Everything worked fine when wrote a batch file - but I want to create a JAR file. In the Batch file I gave the path to those files for the class loader in a loop, and it was "prog.components/" + filename[i] (I get the file names by using a FileFilter).
    My question is - how can I obtain the files in the prog/component directory inside the JAR? WHen I left it as it was in the BATCH it didn't work because there wa no prog/component dir outsiede the JAR. What should I do?

    Thanks man, that was really helpful! I wrote some piece of code that inserts the file names I want to an ArrayList. However, I wonder how you would make the program list all the files in the "prog.jar/prog/components/" directory? I think your code would be better tahn mine since you've coped with it before. Could you write the code snippet?

  • How to run .class files in IE?

    the basic html codes are
    <applet code="<filename>.class" width = 400 height = 400 >
    </applet>
    i have tried on applets and it works but i dont know why it does not when i am using JApplet with swing. i also have placed the html file in the classes directory. when i open IE to load the html file, the applet does not appear and it says unable to find <filename>.class.
    does anyone know why? and what's the correct way?

    which JVM is used by IE? The 1.1.8JVM from IE is very old so you should use a Java2 JVM or a Swing-Plugin for IE

  • How to run ear file in java application server

    i want how to run .ear file in java application server
    1. i m created ear file
    2. i m created jar file (bean,home,remote)
    3.i m created war file(in the form of jsp)
    but till now i couldnt run ear file
    how to run
    please hel me

    You must create :
    1.Jar file
    2.War file
    And then put them into an ear file
    Exemple : myapp.ear contains
    myappEJB.jar
    myappWEB.war
    META-INF/application.xml
    and application.xml looks like this :
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
        <display-name>myapp</display-name>
        <description>Demo application</description>
        <module>
            <ejb>myappEJB.jar</ejb>
        </module>
        <module>
          <web>
             <web-uri>myappWAR.war</web-uri>
             <context-root>/myapp</context-root>
          </web>
        </module>
    </application>Good luck

  • Conversion of a .class file into a .jar file

    Conversion of a .class file into a .jar file
    How Will I convert a .class file into a .jar file.
    Pls answer ASAP.

    You don't.
    You add a .class file into a .jar file. You don't convert anything.
    Read the help page for jar for details.

  • How to run .java file in windows ?

    How to run .java file in windows without installing any program? Thx!

    First, U must make sure that there is JDK on your computer
    Then, set the envionment variables which the os can find your compiler and interpreter: javac java
    after those, you must complie your .java file to .class file, then you can excute it by java, for example " java helloworld"

  • Beginner: Can't convert a hello.class file into a jar file. Please Help!!!

    Hi, I created a hello.java file, converted into a hello.class file by using the java 2SDk compiler. The problem is that the hello.class file is in a directory I created: C:\JavaBuilder\hello.class
    I have a problem converting the hello class file into a jar file. I don't know which approach to take. I've looked at tutorials...but I keep getting more confused each time I view the tutorials on creating jar files. Please can someone help..by taking me through a step by step process. Please be explicit and do not leave or assume that I know any details because I'm a new born beginner. Thank you very much, I seriously appreciate it.

    Hi!
    first of all, you should use an upper-case character for the first letter of your classes...
    To answer your question :
    1) you must create a directory named "meta-inf" in your directory "C:\JavaBuilder"
    2) then,you must create a file named "manifest.mf" in this directory
    it's like a property file and it must contain this :
    Main-Class: hello
    (don't forget to type <enter> after "hello")
    3) in the directory "C:\JavaBuilder", you can enter the following command :
    "jar cvfM hello.jar meta-inf\manifest.mf hello.class"
    (check jar.exe is in your path)
    4) you can run your jar by the command :
    "java -jar hello.jar"

  • How to convert .class file to exec file...

    hi.
    how to convert .class file to exec file...
    please explain me clearly.....
    thanks...

    Placing your exact "question" into google:
    http://www.google.com/search?q=how+to+convert+.class+file+to+exec+file...

  • How to run .exe files with Virtual PC for Mac

    Hey Guys, I'm new around here and with mac technology as well. Anyway, I have an iMac OS X 10.5.1 Leopard and I've recently purchased the Virtual PC for Mac 7.0.2 software. So I'd like to know how to use this program properly, because I need to run some executable files in my computer. It is confusing for me because I don't know how to get started, and I only get to the part when it says "OS not found, Install an OS on this hard drive".
    Honestly I've no idea of what an OS is or where do I get that. So I'd really appreciate if one of you guys could tell me, step by step, what to do to use Virtual PC properly, and finally learn how to run .exe files on mac.
    Thanks in advance!
    Have a nice day!

    Always nice to see new faces
    Honestly I've no idea of what an OS is or where do I get that.
    This brings up the second part of your problem. The first part is setting up either a proper Virtual Machine program like Parallels or VMfusion, or setting up a Boot Camp partition on your drive.
    http://www.parallels.com/
    http://www.vmware.com/products/fusion/
    OS stands for Operating System. You are running Leopard 10.5.7 as an operating system on your Mac (MacOS X).
    The second part of your problem - You will need a copy of Windows XP or Vista if you want to run Windows on your Mac.
    There is at least one other solution for running Windows programs on a Mac. It's called "CrossOver" by a company named 'Codeweavers'. It's based on a project for "Wine" to be able to run PC programs on a Mac or Linux, without having to buy or install Windows. It works with a narrow subset of Windows programs so you would want to make sure the program you want to run is compatible with CrossOver before you buy it.
    http://www.codeweavers.com/products/cxmac/
    In addition to all the above information, you need to upgrade your Mac to the latest 10.5.7 from 10.5.1. "Software Update" is located under the black Apple icon in the Menu Bar at the top left corner of your monitor. After you are updated you will want to update your Profile here so that it shows the proper OS version.
    With your level of experience with MacOS X and the Windows OS's you should probably get some help from a local Apple store. They have an appointment system and do offer many types of help and training, and they can offer assistance with choosing the proper programs for you to purchase for your machine.
    You are also welcome to continue to ask questions here, of course. You will want to ask your questions with different issues that come up in different threads so that the answers stay focused on the title of the thread.
    Message was edited by: dechamp to try to be more accurate with a fairly complicated issue...

  • How to run .exe files in mac pro?

    how to run .exe files in mac pro?
    i am looking for this to play games in my mac pro.
    if someone got a answer, just let me know
    cheers.

    mailking wrote:
    And I fail to see why you are attacking me...
    My comment is Valid...  " .exe files will not run natively on Mac OS X..."
    I am sorry. I had the false impression that it was commonly known that .exe files did not run on Mac OSX natively and failed to see any constructive critique you were bringing. Maybe I am wrong. Again deepest apologies.
    Unfortunately... these days... not every one is aware of this .exe  fact..
    Apology accepted.. and Thank You..

  • Running class files from the windows command line...

    Hello Everyone,
    My instructor showed us a way to run class files from the windows command line. However every time I try to run the class file from the command line using a command like: java CruiseHelper.class
    I get an error that states "Exception in thread "main" java.lang.NoClassDefFoundError: CruiseHelper/class"

    Hello Everyone,
    My instructor showed us a way to run class files from
    the windows command line. However every time I try
    to run the class file from the command line using a
    command like: java CruiseHelper.class
    I get an error that states "Exception in thread
    "main" java.lang.NoClassDefFoundError:
    CruiseHelper/class"Classes are not file names. You don't have a class named "CruiseHelper.class", that's a file name. The class name is just CruiseHelper (if you have no package statement in it).
    So,
    java -classpath . CruiseHelper

  • How to run script file ( unix script file like ksh or sh file) using Java

    How to run script file ( unix script file like ksh or sh file) using Java Program?.
    I am using the following code snippet to run the simple commands like top or ls ,etc....
    Runtime runtime = Runtime.getRuntime();
    Process proc = runtime.exec("top");
    Thanks In Adavance
    -Siva

    String [] { "ksh" , "-c" , "script", "arg 1", "arg 2", "arg 3"}

  • How to run .sql file in tsql or powershell

    Hi All,
    HOw to run .sql file inside the TSQL or powershell using with IF else condition. This below query works fine but when i executing through the SQL Agent it's geeting an error.Please could help how to run through the SQL agent already using execution type
    in agent as 'Operating system(CmdExec)'
    Declare @computerName varchar(100), @InstanceName varchar(50)                             
    SET @ComputerName = REPLACE(CAST(SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS varchar),'\','$')  
    SET @InstanceName = REPLACE(CAST(SERVERPROPERTY('instancename') AS varchar),'\','$')
    IF (@InstanceName = 'SQL2008R2')
    Begin  
    :r C:\BackupFolder\Test1.sql    
    :r C:\BackupFolder\Test2.sql    
    End
    IF (@InstanceName = 'SQLINS2')
    BEGIN
    :r C:\BackupFolder\Test3.sql
    END
    IF (@InstanceName = 'SQL2012')
    BEGIN
    :r C:\BackupFolder\Test4.sql
    END
    Thansk in Advance
    A-ZSQL

    In T-SQL, you can try using sqlcmd to invoke sql file
    if @@SERVERNAME='abcd'
    begin
    Master..xp_cmdshell 'sqlcmd -S <ServerName> -i BackupDetails.sql -E'
    end
    OR 
     PowerShell 
    Load the snapins
    Add-PSSnapin SqlServerCmdletSnapin100
    Add-PSSnapin SqlServerProviderSnapin100
    Function Get-SqlInstances {
    Param($ServerName = '.')
    $localInstances = @()
    [array]$captions = gwmi win32_service -computerName $ServerName | ?{$_.Name -match "mssql*" -and $_.PathName -match "sqlservr.exe"} | %{$_.Caption}
    foreach ($caption in $captions) {
    if ($caption -like "MSSQLSERVER") {
    $localInstances += $ServerName
    } else {
    $temp = $caption | %{$_.split(" ")[-1]} | %{$_.trimStart("(")} | %{$_.trimEnd(")")}
    $localInstances += "$ServerName\$temp"
    $localInstances
    $instance=Get-SqlInstances -ServerName HQDBSP17
    foreach($i in $instance)
    if($i -like 'CRM2011')
    write-host 'CRM Database'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    if( $i -like 'SQL2012')
    write-host 'SQL 2012 instance'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    --Prashanth

  • How to run media file after Runtime.exc the real player?

    Hi
    How to run media file after Runtime.exc the real player application

    String command = "cmd /c start videotest.rm";
    Runtime.getRuntime().exec(command);

Maybe you are looking for