Как правильно скомпилировать этот файл с помощью javacJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Как правильно скомпилировать этот файл с помощью javac

Сообщение Anonymous »

У меня есть следующий файл под названием Test.Java, код которого:

Код: Выделить всё

package example25;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Iterator;
import org.jibx.runtime.BindingDirectory;
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.IMarshallingContext;
import org.jibx.runtime.IUnmarshallingContext;
import org.jibx.runtime.JiBXException;

public class Test
{
public static void main(String[] args)
{

try
{

// unmarshal customer information from file
IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
FileInputStream in = new FileInputStream("D:\\Java Libraries\\jibx\\dwcode2\\starter.xml");
Order order = (Order)uctx.unmarshalDocument(in, null);

// compute the total amount of the order
float total = 0.0f;
for (Iterator iter = order.getItemList().iterator(); iter.hasNext();)
{
Item item = iter.next();
total += item.getPrice() * item.getQuantity();
}
order.setTotal(new Float(total));

// marshal object back out to file (with nice indentation, as UTF-8)
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
FileOutputStream out = new FileOutputStream("c:\\out.xml");
mctx.setOutput(out, null);
mctx.marshalDocument(order);
System.out.println("Processed order with " +  order.getItemList().size() + " items and total value " + total);

}
catch (FileNotFoundException e)
{
e.printStackTrace();
System.exit(1);
} catch (JiBXException e)
{
e.printStackTrace();
System.exit(1);
}
}//end main

}//end class
Вот как я пытаюсь скомпилировать этот файл и получаю результат

Код: Выделить всё

C:\jibx\tutorial>javac example25\Test.java
example25\Test.java:8: error: package org.jibx.runtime does not exist
import org.jibx.runtime.BindingDirectory;
^
example25\Test.java:9: error: package org.jibx.runtime does not exist
import org.jibx.runtime.IBindingFactory;
^
example25\Test.java:10: error: package org.jibx.runtime does not exist
import org.jibx.runtime.IMarshallingContext;
^
example25\Test.java:11: error: package org.jibx.runtime does not exist
import org.jibx.runtime.IUnmarshallingContext;
^
example25\Test.java:12: error: package org.jibx.runtime does not exist
import org.jibx.runtime.JiBXException;
^
example25\Test.java:25: error: cannot find symbol
IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
^
symbol:   class IBindingFactory
location: class Test
example25\Test.java:25: error: cannot find symbol
IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
^
symbol:   variable BindingDirectory
location: class Test
example25\Test.java:26: error: cannot find symbol
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
^
symbol:   class IUnmarshallingContext
location: class Test
example25\Test.java:40: error: cannot find symbol
IMarshallingContext mctx = bfact.createMarshallingContext();
^
symbol:   class IMarshallingContext
location: class Test
example25\Test.java:52: error: cannot find symbol
} catch (JiBXException e)
^
symbol:   class JiBXException
location: class Test
10 errors
Все файлы классов, используемые Test, присутствуют рядом с ним и были правильно скомпилированы.
Test — последний файл, который доставляет мне неприятности. Кроме того, некоторые классы, используемые в тесте, присутствуют в C:\jibx\lib>, а не в C:\jibx\tutorial>, откуда я выполняю команды. Будем признательны за любые предложения о том, как решить эту проблему без изменения ранее созданных файлов классов.

Подробнее здесь: https://stackoverflow.com/questions/104 ... sing-javac
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»